【发布时间】:2011-12-31 12:49:54
【问题描述】:
我正在使用 FFmpeg 从视频文件的特定位置提取缩略图。
我在网上找到了两种方法:
-
-ss(搜索)参数在-i(输入)参数之前:ffmpeg -y -ss $SEEK_POINT -i input.ogv -vcodec mjpeg -vframes 1 -an -s 120x90 -f rawvideo output.jpg -
在
-i(输入)参数之后加上-ss(搜索)参数:ffmpeg -y -i input.ogv -vcodec mjpeg -ss $SEEK_POINT -vframes 1 -an -s 120x90 -f rawvideo output.jpg
第一种方法会生成带有灰点的糟糕缩略图,但运行速度非常快。返回的错误是[theora @ 0x8097240] vp3: first frame not a keyframe。
第二种方法总是有效,但会显示一个错误,导致提取需要很长时间。这个时间量不是固定的,它取决于我注意到的搜索点。有时需要几秒钟,有时需要几分钟来提取缩略图。我在以下输出中收到错误 Buffering several frames is not supported. Please consume all available frames before adding a new one.:
Input #0, ogg, from 'input.ogv':
Duration: 00:21:52.76, start: 0.000000, bitrate: 844 kb/s
Stream #0.0: Video: theora, yuv420p, 800x600 [PAR 4:3 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
Stream #0.1: Audio: vorbis, 44100 Hz, stereo, s16, 192 kb/s
Metadata:
ENCODER : Lavf52.102.0
Incompatible pixel format 'yuv420p' for codec 'mjpeg', auto-selecting format 'yuvj420p'
[buffer @ 0x9250840] w:800 h:600 pixfmt:yuv420p
[scale @ 0x92508a0] w:800 h:600 fmt:yuv420p -> w:120 h:90 fmt:yuvj420p flags:0x4
Output #0, rawvideo, to 'output.jpg':
Metadata:
encoder : Lavf53.2.0
Stream #0.0: Video: mjpeg, yuvj420p, 120x90 [PAR 4:3 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
Stream #0.0 -> #0.0
Press ctrl-c to stop encoding
[buffer @ 0x9250840] Buffering several frames is not supported. Please consume all available frames before adding a new one.
frame= 0 fps= 0 q=0.0 size= 0kB time=10000000000.00 bitrate= 0.0kbit
Last message repeated 15448 times
frame= 1 fps= 0 q=3.4 Lsize= 3kB time=0.04 bitrate= 598.8kbits/s
video:3kB audio:0kB global headers:0kB muxing overhead 0.000000%
无论输入格式如何,如何使用 FFmpeg 从视频的自定义位置毫无问题地提取缩略图?
【问题讨论】:
标签: video ffmpeg thumbnails