ffmpeg可以提取隐藏字幕数据吗 [英] Can ffmpeg extract closed caption data
问题描述
我目前正在使用ffmpeg将各种格式的视频转换为flv文件.还提出了一个请求,那就是也从文件中获取隐藏字幕信息.有没有人对此有任何经验或知道可以做到这一点?我看不到任何选择,但想问一问.
I am currently using ffmpeg to convert videos in various formats to flv files. One request has also come up and that is to get closed caption info out o the file as well. Does anyone have any experience with this or know it can even be done. I don't see any options for it but thought I would ask and see.
推荐答案
如果像我这样的人最后出现在此线程上,这是对我有用的ffmpeg
命令的更详细的说明.
If anyone, like me, ends up on this thread, here's a bit more detailed explanation on ffmpeg
command that worked for me.
ffmpeg -f lavfi -i movie=input.ts[out+subcc] -map 0:1 output.srt
似乎对源的硬性要求是mpegts
格式(文件扩展名.ts
).否则,lavfi
过滤器似乎不起作用.规范out+subcc
强制ffmpeg将隐藏式字幕(嵌入到帧数据中)视为单独的流.后来-map 0:1
使ffmpeg
仅映射该流,并丢弃其他所有内容.结果保存到output.srt
.根据您的输入,映射可能会有所不同.找出隐藏字幕映射的一种简单方法是像这样运行ffprobe
命令
There seems a hard requirement on source to be of mpegts
format (file extension .ts
). Otherwise the lavfi
filter does not seem to work. The spec out+subcc
forces ffmpeg to treat closed captions (which are embedded into frame data) as separate stream. Later -map 0:1
makes ffmpeg
map only that stream and discard everything else. Result is saved to output.srt
. Depending on your input the mapping might be different. One easy way to figure out the closed captions mapping is to run ffprobe
command, like so
$ ffprobe -f lavfi -i movie=input.ts[out+subcc]
ffprobe version N-79653-g4efd3ec Copyright (c) 2007-2016 the FFmpeg developers
libavutil 55. 22.101 / 55. 22.101
libavcodec 57. 38.100 / 57. 38.100
libavformat 57. 34.103 / 57. 34.103
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 44.100 / 6. 44.100
libswscale 4. 1.100 / 4. 1.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[h264 @ 0x7fe869826200] Increasing reorder buffer to 1
Input #0, lavfi, from 'movie=input.ts[out+subcc]':
Duration: N/A, start: 1562.233011, bitrate: N/A
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 90k fps, 30 tbr, 90k tbn
Stream #0:1: Subtitle: eia_608
流Subtitle: eia_608
具有索引" 0:1
,因此应进行映射.
Stream Subtitle: eia_608
has "index" 0:1
, so that is what should be mapped.
很少有分开的注释,对于ffmpeg
来说,参数顺序很重要,-f lavfi
必须在-i move=...
之前,否则规格将无法识别.另外,此功能是最近才推出的,因此请仔细检查您的ffmpeg
版本并根据需要进行升级.
Few parting notes, order of arguments matters for ffmpeg
, -f lavfi
must go before -i move=...
, otherwise the spec will not be recognized. Also this feature is pretty recent, so double check your ffmpeg
version and upgrade if needed.
这篇关于ffmpeg可以提取隐藏字幕数据吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!