Strange “pause” in video after concatenation of two mp4 videos

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

I am concatenating two mp4 videos. The problem is that first video (intro.mp4) lasts 5 seconds, second video (output.mp4) lasts 2 seconds and video created by concatenating them lasts 9 seconds (and should last 5+2 = 7 seconds). In final.mp4 video the last frame from first video (intro.mp4) i shown for additional 2 seconds before second video (output.mp4) is played. It looks like a lag when watching video. What I am doing wrong?

list.txt:

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

command:

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

output:

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% 

回答1:

I was having the same problem with 2 mpg files. I was using this command:

ffmpeg -i "concat:foo.mpg|bar.mpg|" -c copy out.mpg

I found this link:

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

which suggested setting the duration explicitly with the duration directive in an input file, i.e. a file looking like this:

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

where the numbers are in seconds.

Oddly, when I switched to using an input list from a file, the problem went away even without setting the duration. Very odd. I double checked and consistently got the pause with the command line list and none with the file list in a text file.. Obviously that's not working for you, as you've already got an input list file, but the duration trick might be worth a try.



易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!