如何使用 ffmpeg 从 avi 中精确剪切帧

如何使用 ffmpeg 从 avi 中精确剪切帧

我使用下面的命令将其剪切为帧。我想要 48 帧的视频,即 7 秒。

ffmpeg -i output.avi -r 6.4 -s sxga images\\image%d.jpeg

它为我创建了帧,但我将它用于不同的视频,它给出了不同的结果。output.avi 为 7 秒,但它为我提供了 46 - 50 帧,具体取决于我插入的输出视频。

第一个视频的命令行输出是:

>ffmpeg -i "only7s.avi" -r 6.4 -s sxga images\\image%d.jpeg
ffmpeg version N-62121-g634636e Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr  3 2014 23:30:16 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable
-zlib
  libavutil      52. 73.100 / 52. 73.100
  libavcodec     55. 56.107 / 55. 56.107
  libavformat    55. 36.101 / 55. 36.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, avi, from 'only7s.avi':
  Metadata:
    encoder         : Lavf55.36.101
  Duration: 00:00:07.04, start: 0.000000, bitrate: 4890 kb/s
    Stream #0:0: Video: h264 (High) (H264 / 0x34363248), yuv420p, 1024x768, 4924
 kb/s, 30 fps, 30 tbr, 30 tbn, 59.99 tbc
    Stream #0:1: Audio: aac ([255][0][0][0] / 0x00FF), 44100 Hz, stereo, fltp, 1
28 kb/s
[swscaler @ 0358bec0] deprecated pixel format used, make sure you did set range
correctly
Output #0, image2, to 'images\\image%d.jpeg':
  Metadata:
    encoder         : Lavf55.36.101
    Stream #0:0: Video: mjpeg, yuvj420p, 1280x1024, q=2-31, 200 kb/s, 90k tbn, 6
.40 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> mjpeg)
Press [q] to stop, [?] for help
*** dropping frame 8 from stream 0 at ts 5
*** dropping frame 9 from stream 0 at ts 6
    Last message repeated 3 times
*** dropping frame 10 from stream 0 at ts 7
    Last message repeated 3 times
frame=   11 fps=0.0 q=22.7 size=N/A time=00:00:01.71 bitrate=N/A dup=4 drop=9
*** dropping frame 11 from stream 0 at ts 8
    Last message repeated 2 times
*** dropping frame 12 from stream 0 at ts 9
    Last message repeated 3 times
*** dropping frame 13 from stream 0 at ts 10
    Last message repeated 3 times
*** dropping frame 14 from stream 0 at ts 11
    Last message repeated 1 times
*** dropping frame 15 from stream 0 at ts 12
*** dropping frame 16 from stream 0 at ts 13
    Last message repeated 1 times
*** dropping frame 17 from stream 0 at ts 14
*** dropping frame 18 from stream 0 at ts 15
frame=   19 fps= 18 q=24.8 size=N/A time=00:00:02.96 bitrate=N/A dup=4 drop=27
*** dropping frame 19 from stream 0 at ts 16
    Last message repeated 1 times
*** dropping frame 20 from stream 0 at ts 17
*** dropping frame 21 from stream 0 at ts 18
*** dropping frame 22 from stream 0 at ts 19
    Last message repeated 1 times
*** dropping frame 23 from stream 0 at ts 20
*** dropping frame 24 from stream 0 at ts 21
frame=   24 fps= 15 q=24.8 size=N/A time=00:00:03.75 bitrate=N/A dup=4 drop=35
*** dropping frame 25 from stream 0 at ts 22
    Last message repeated 1 times
*** dropping frame 26 from stream 0 at ts 23
*** dropping frame 27 from stream 0 at ts 24
*** dropping frame 28 from stream 0 at ts 25
    Last message repeated 1 times
*** dropping frame 29 from stream 0 at ts 26
*** dropping frame 30 from stream 0 at ts 27
*** dropping frame 31 from stream 0 at ts 28
frame=   31 fps= 15 q=24.8 size=N/A time=00:00:04.84 bitrate=N/A dup=4 drop=44
*** dropping frame 31 from stream 0 at ts 28
*** dropping frame 32 from stream 0 at ts 29
*** dropping frame 33 from stream 0 at ts 30
*** dropping frame 34 from stream 0 at ts 31
    Last message repeated 1 times
*** dropping frame 35 from stream 0 at ts 32
*** dropping frame 36 from stream 0 at ts 33
    Last message repeated 1 times
frame=   37 fps= 14 q=24.8 size=N/A time=00:00:05.78 bitrate=N/A dup=4 drop=52
*** dropping frame 37 from stream 0 at ts 34
*** dropping frame 38 from stream 0 at ts 35
*** dropping frame 39 from stream 0 at ts 36
    Last message repeated 1 times
*** dropping frame 40 from stream 0 at ts 37
*** dropping frame 41 from stream 0 at ts 38
*** dropping frame 42 from stream 0 at ts 39
    Last message repeated 1 times
frame=   43 fps= 14 q=24.8 size=N/A time=00:00:06.71 bitrate=N/A dup=4 drop=60
*** dropping frame 43 from stream 0 at ts 40
*** dropping frame 44 from stream 0 at ts 41
*** dropping frame 45 from stream 0 at ts 42
    Last message repeated 1 times
*** dropping frame 46 from stream 0 at ts 43
*** dropping frame 47 from stream 0 at ts 44
frame=   47 fps= 13 q=24.8 Lsize=N/A time=00:00:07.34 bitrate=N/A dup=4 drop=66

video:2537kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 709977824034816.000000%

第二个视频的命令行输出是:

>ffmpeg -i "C:\ArtWedding\bin\x86\Debug\flipvideo\video180327.avi" -r 6.4 -s sxg
a images\\image%d.jpeg
ffmpeg version N-62121-g634636e Copyright (c) 2000-2014 the FFmpeg developers
  built on Apr  3 2014 23:30:16 with gcc 4.8.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp
e --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --ena
ble-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-l
ibopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libsp
eex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-aa
cenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavp
ack --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable
-zlib
  libavutil      52. 73.100 / 52. 73.100
  libavcodec     55. 56.107 / 55. 56.107
  libavformat    55. 36.101 / 55. 36.101
  libavdevice    55. 11.100 / 55. 11.100
  libavfilter     4.  3.100 /  4.  3.100
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, avi, from 'C:\ArtWedding\bin\x86\Debug\flipvideo\video180327.avi':
  Metadata:
    encoder         : Lavf55.36.101
  Duration: 00:00:07.47, start: 0.000000, bitrate: 128364 kb/s
    Stream #0:0: Video: rawvideo, bgr24, 640x480, 128928 kb/s, 30 tbr, 30 tbn, 3
0 tbc
[swscaler @ 029adf40] deprecated pixel format used, make sure you did set range
correctly
Output #0, image2, to 'images\\image%d.jpeg':
  Metadata:
    encoder         : Lavf55.36.101
    Stream #0:0: Video: mjpeg, yuvj444p, 1280x1024, q=2-31, 200 kb/s, 90k tbn, 6
.40 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo -> mjpeg)
Press [q] to stop, [?] for help
*** dropping frame 10 from stream 0 at ts 7
frame=   10 fps=0.0 q=19.9 size=N/A time=00:00:01.56 bitrate=N/A dup=1 drop=1
*** dropping frame 10 from stream 0 at ts 7
*** dropping frame 11 from stream 0 at ts 8
    Last message repeated 2 times
*** dropping frame 12 from stream 0 at ts 9
*** dropping frame 13 from stream 0 at ts 10
    Last message repeated 1 times
*** dropping frame 14 from stream 0 at ts 11
*** dropping frame 15 from stream 0 at ts 12
frame=   16 fps= 16 q=24.8 size=N/A time=00:00:02.50 bitrate=N/A dup=1 drop=10
*** dropping frame 16 from stream 0 at ts 13
*** dropping frame 17 from stream 0 at ts 14
    Last message repeated 2 times
*** dropping frame 18 from stream 0 at ts 15
    Last message repeated 3 times
*** dropping frame 19 from stream 0 at ts 16
*** dropping frame 21 from stream 0 at ts 18
frame=   21 fps= 14 q=24.8 size=N/A time=00:00:03.28 bitrate=N/A dup=1 drop=20
*** dropping frame 23 from stream 0 at ts 20
*** dropping frame 24 from stream 0 at ts 21
*** dropping frame 25 from stream 0 at ts 22
*** dropping frame 27 from stream 0 at ts 24
frame=   28 fps= 14 q=24.8 size=N/A time=00:00:04.37 bitrate=N/A dup=1 drop=24
*** dropping frame 29 from stream 0 at ts 26
*** dropping frame 31 from stream 0 at ts 28
*** dropping frame 33 from stream 0 at ts 30
*** dropping frame 34 from stream 0 at ts 31
    Last message repeated 2 times
frame=   34 fps= 13 q=24.8 size=N/A time=00:00:05.31 bitrate=N/A dup=1 drop=30
*** dropping frame 35 from stream 0 at ts 32
    Last message repeated 1 times
*** dropping frame 36 from stream 0 at ts 33
    Last message repeated 3 times
*** dropping frame 37 from stream 0 at ts 34
    Last message repeated 2 times
*** dropping frame 38 from stream 0 at ts 35
    Last message repeated 3 times
frame=   39 fps= 13 q=24.8 size=N/A time=00:00:06.09 bitrate=N/A dup=1 drop=43
*** dropping frame 39 from stream 0 at ts 36
    Last message repeated 3 times
*** dropping frame 40 from stream 0 at ts 37
    Last message repeated 2 times
*** dropping frame 41 from stream 0 at ts 38
    Last message repeated 2 times
*** dropping frame 42 from stream 0 at ts 39
    Last message repeated 1 times
*** dropping frame 43 from stream 0 at ts 40
frame=   43 fps= 12 q=24.8 size=N/A time=00:00:06.71 bitrate=N/A dup=1 drop=56
*** dropping frame 44 from stream 0 at ts 41
    Last message repeated 3 times
*** dropping frame 45 from stream 0 at ts 42
    Last message repeated 3 times
*** dropping frame 46 from stream 0 at ts 43
    Last message repeated 2 times
*** dropping frame 47 from stream 0 at ts 44
    Last message repeated 2 times
frame=   47 fps= 11 q=24.8 size=N/A time=00:00:07.34 bitrate=N/A dup=1 drop=70
*** dropping frame 48 from stream 0 at ts 45
    Last message repeated 2 times
*** dropping frame 49 from stream 0 at ts 46
    Last message repeated 2 times
*** dropping frame 50 from stream 0 at ts 47
    Last message repeated 1 times
frame=   50 fps= 11 q=24.8 size=N/A time=00:00:07.81 bitrate=N/A dup=1 drop=78
*** dropping frame 50 from stream 0 at ts 47
    Last message repeated 1 times
frame=   51 fps= 11 q=24.8 Lsize=N/A time=00:00:07.96 bitrate=N/A dup=1 drop=80

video:4415kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: 407988875558912.000000%

相关内容