【问题标题】:Strange "pause" in video after concatenation of two mp4 videos连接两个 mp4 视频后,视频中出现奇怪的“暂停”
【发布时间】:2021-01-23 23:32:08
【问题描述】:

我正在连接两个 mp4 视频。问题是第一个视频(intro.mp4)持续 5 秒,第二个视频(output.mp4)持续 2 秒,通过连接它们创建的视频持续 9 秒(并且应该持续 5+2 = 7 秒)。在 final.mp4 视频中,第一个视频 (intro.mp4) 的最后一帧在播放第二个视频 (output.mp4) 之前额外显示了 2 秒。看视频时好像有延迟。我做错了什么?

list.txt:

file 'data/intro.mp4'
file 'output.mp4'

命令:

./bin/ffmpeg -f concat -i list.txt -c copy final.mp4

输出:

ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
  built with llvm-gcc 4.2.1 (LLVM build 2336.11.00)
  configuration: --prefix=/Volumes/Ramdisk/sw --enable-gpl --enable-pthreads --enable-version3 --enable-libspeex --enable-libvpx --disable-decoder=libvpx --enable-libmp3lame --enable-libtheora --enable-libvorbis --enable-libx264 --enable-avfilter --enable-libopencore_amrwb --enable-libopencore_amrnb --enable-filters --enable-libgsm --enable-libvidstab --enable-libx265 --disable-doc --arch=x86_64 --enable-runtime-cpudetect
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8a6a80e600] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'list.txt':
  Duration: N/A, start: 0.000000, bitrate: 1296 kb/s
    Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 960x540, 1163 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc
    Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 133 kb/s
[mp4 @ 0x7f8a6c006a00] Codec for stream 0 does not use global headers but container format requires global headers
[mp4 @ 0x7f8a6c006a00] Codec for stream 1 does not use global headers but container format requires global headers
Output #0, mp4, to 'final.mp4':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv420p, 960x540, q=2-31, 1163 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 11988 tbc
    Stream #0:1: Audio: aac ([64][0][0][0] / 0x0040), 48000 Hz, stereo, 133 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f8a6a80e600] Auto-inserting h264_mp4toannexb bitstream filter
frame=  258 fps=0.0 q=-1.0 Lsize=     997kB time=00:00:09.84 bitrate= 829.5kbits/s    
video:897kB audio:93kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.634306%

【问题讨论】:

  • 视频是否以相同的方式编码 - mp4 文件中的相同视频和音频编解码器? ffmpeg mp4 concat 你使用它的方式只有在这种情况下才能正常工作,我认为。
  • 我也看到了这个问题。文件是来自同一相机的两个连续 mpg,相隔几秒钟。我很确定它们都是相同的编解码器和格式。

标签: video ffmpeg video-processing


【解决方案1】:

我在处理 2 个 mpg 文件时遇到了同样的问题。我正在使用这个命令:

ffmpeg -i "concat:foo.mpg|bar.mpg|" -c 复制出.mpg

我找到了这个链接:

https://ffmpeg.org/pipermail/ffmpeg-user/2013-March/013933.html

它建议在输入文件中使用持续时间指令明确设置持续时间,即看起来像这样的文件:

file foo.mpg
duration 6
file bar.mpg
duration 4.5

数字以秒为单位。

奇怪的是,当我切换到使用文件中的输入列表时,即使没有设置持续时间,问题也消失了。很奇怪。我仔细检查并始终使用命令行列表暂停,而文本文件中的文件列表则没有。显然这对您不起作用,因为您已经有了一个输入列表文件,但是持续时间技巧可能值得试一试。

【讨论】:

    【解决方案2】:

    对我来说,当我的视频文件长度不仅以秒为单位,而且以毫秒为单位时,就会发生这种情况。小小的停顿是拉伸最后一帧直到填满那一秒。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-03-17
      • 1970-01-01
      • 2018-04-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-04
      相关资源
      最近更新 更多