我想从固定间隔的视频中提取一些帧,所以我使用了命令行:
ffmpeg.exe -i input.mp4 -r 5 results\%d.jpg`
但是,前几帧之间的间隔与其余帧的间隔不同。
例如,如果我同时执行ffmpeg.exe -i input.mp4 -r 25 -t 5 test\%d.jpg
和ffmpeg.exe -i input.mp4 -r 5 -t 5 test2\%d.jpg
(对于fps 25视频),我希望test2
中的结果是test
结果的子序列1}}与间隔5.然而我得到的是:
Screenshot of results
从缩略图中,test
中的图像112~125显然不会出现在test2
中。一些仔细检查发现两组结果之间的对应关系如下:
test | test2
1&2 | 1&2 (Those two frames are identical)
3 | 3
4 | 4
9 | 5
14 | 6
19 | 7
... | ...
104 | 24
109 | 25
(实际上,在比较最后一帧时,我刚刚意识到test
中的结果有太多马赛克。我通过添加选项-q:v 1
来修复此问题。)
可以看出,test2
的前几帧实际上有间隔1,而不是预期值5.
此行为的原因是什么,以及如何解决?
如果有人想看到ffmpeg输出:
PS C:\Users\<username>\Documents\New folder> ffmpeg.exe -i input.mp4 -r 25 -t 5 test\%d.jpg
ffmpeg version N-50911-g9efcfbe Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 13 2013 21:26:48 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi
g --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libg
sm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --ena
ble-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-lib
twolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxa
vs --enable-libxvid --enable-zlib
libavutil 52. 19.100 / 52. 19.100
libavcodec 55. 0.100 / 55. 0.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 54. 4.100 / 54. 4.100
libavfilter 3. 45.103 / 3. 45.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2015-05-05 04:46:16
Duration: 00:49:04.96, start: 0.000000, bitrate: 386 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 524x360 [SAR 1:1 DAR 131:90], 287
kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s
Metadata:
creation_time : 2015-05-05 04:46:21
handler_name : IsoMedia File Produced by Google, 5-11-2011
Output #0, image2, to 'test\%d.jpg':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf55.0.100
Stream #0:0(und): Video: mjpeg, yuvj420p, 524x360 [SAR 1:1 DAR 131:90], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame= 125 fps=0.0 q=0.0 Lsize=N/A time=00:00:05.00 bitrate=N/A
video:1140kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.001884%
PS C:\Users\<username>\Documents\New folder> ffmpeg.exe -i input.mp4 -r 5 -t 5 test2\%d.jpg
ffmpeg version N-50911-g9efcfbe Copyright (c) 2000-2013 the FFmpeg developers
built on Mar 13 2013 21:26:48 with gcc 4.7.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfi
g --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libg
sm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --ena
ble-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-lib
twolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxa
vs --enable-libxvid --enable-zlib
libavutil 52. 19.100 / 52. 19.100
libavcodec 55. 0.100 / 55. 0.100
libavformat 55. 0.100 / 55. 0.100
libavdevice 54. 4.100 / 54. 4.100
libavfilter 3. 45.103 / 3. 45.103
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 2.100 / 52. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2015-05-05 04:46:16
Duration: 00:49:04.96, start: 0.000000, bitrate: 386 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 524x360 [SAR 1:1 DAR 131:90], 287
kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 96 kb/s
Metadata:
creation_time : 2015-05-05 04:46:21
handler_name : IsoMedia File Produced by Google, 5-11-2011
Output #0, image2, to 'test2\%d.jpg':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
encoder : Lavf55.0.100
Stream #0:0(und): Video: mjpeg, yuvj420p, 524x360 [SAR 1:1 DAR 131:90], q=2-31, 200 kb/s, 90k tbn, 5 tbc
Metadata:
handler_name : VideoHandler
Stream mapping:
Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
frame= 25 fps=0.0 q=0.0 Lsize=N/A time=00:00:05.00 bitrate=N/A dup=0 drop=88
video:375kB audio:0kB subtitle:0 global headers:0kB muxing overhead -100.005728%