使用 ffmpeg concat 连接视频文件时出现视频长度问题

使用 ffmpeg concat 连接视频文件时出现视频长度问题

我有 3 个视频:

  • open.avi– 持续时间为 0:46:37.885933
  • middle.avi– 0:02:56.991927 时长
  • fin.avi– 0:02:48.199268 时长

我尝试使用命令连接 3 个视频:

$ ffmpeg -i "concat:fin.avi|open.avi|middle.avi" -preset ultrafast -c copy -y vide.avi

ffmpeg version 1.2.4 Copyright (c) 2000-2013 the FFmpeg developers
  built on Oct 16 2013 22:38:01 with gcc 4.8.1 (GCC) 20130603 (Red Hat 4.8.1-1)
  configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib --mandir=/usr/share/man --arch=i686 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -grecord-gcc-switches -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --enable-bzlib --disable-crystalhd --enable-frei0r --enable-gnutls --enable-libass --enable-libcelt --enable-libdc1394 --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopencv --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libvpx --enable-libx264 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib --cpu=i686 --enable-runtime-cpudetect
  libavutil      52. 18.100 / 52. 18.100
  libavcodec     54. 92.100 / 54. 92.100
  libavformat    54. 63.104 / 54. 63.104
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 42.103 /  3. 42.103
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, avi, from 'concat:fin.avi|open.avi|middle.avi':
  Duration: 00:02:48.20, start: 0.000000, bitrate: 28159 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p, 640x480, 11.20 tbr, 11.20 tbn, 11.20 tbc
Output #0, avi, to 'vide.avi':
  Metadata:
    ISFT            : Lavf54.63.104
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p, 640x480, q=2-31, 11.20 tbn, 11.20 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=27988 fps=2386 q=-1.0 Lsize=  578159kB time=00:41:38.70 bitrate=1895.5kbits/s    
video:577498kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.114549%

当我改变输入视频的顺序时:

    Input #0, avi, from 'concat:open.avi|middle.avi|fin.avi':
  Duration: 00:46:37.89, start: 0.000000, bitrate: 1692 kb/s
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p, 640x480, 8.61 tbr, 8.61 tbn, 8.61 tbc
Output #0, avi, to 'vide.avi':
  Metadata:
    ISFT            : Lavf54.63.104
    Stream #0:0: Video: mjpeg (MJPG / 0x47504A4D), yuvj422p, 640x480, q=2-31, 8.61 tbn, 8.61 tbc
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
frame=27988 fps=2343 q=-1.0 Lsize=  578159kB time=00:54:11.01 bitrate=1456.9kbits/s    
video:577498kB audio:0kB subtitle:0 global headers:0kB muxing overhead 0.114549%

我该如何修复它?

答案1

我通过使用复制流选项重新运行ffmpeg连接输出来修复此问题。因此,使用您的文件名,它将是:

ffmpeg -i vide.avi -c copy vide_fixed.avi

不过,我还没有用 avi 测试过。我使用的是 mp4。

相关内容