使用FFmpeg连接不同格式的视频块

时间:2014-04-12 03:16:17

标签: video ffmpeg

我最近在探索FFmpeg的功能。我有两种不同格式的视频(例如mov和mp4)。我将首先将这些视频拆分为较小的块,并将这两个视频中的各种块混合在一起。但是,连接的视频无法正常显示。我做了一些研究,发现mp4不能使用常规连接方法连接,因为它包含额外的头和信息。因此我首先将所有视频转换为mpg,将它们拆分,然后将转换连接回mp4。但是,仍然没有运气。

以下是我使用的命令:

// convert input (1st video) to mpg
ffmpeg -i input.mp4 input.mpg

// convert to keyframe video
ffmpeg -i input.mpg -strict -2 -g 20 keyframe_input.mpg

// split keyframe_input into smaller chunks
ffmpeg -i keyframe_input.mpg -acodec copy -f segment -segment_time 0.3 -segment_list  s.m3u8 -vcodec copy -reset_timestamps 1 -map 0 split_input-%d.mpg

// convert input2 (2nd video) to mpg
ffmpeg -i input2.mov input2.mpg

// convert to keyframe video
ffmpeg -i input2.mpg -strict -2 -g 20 keyframe_input2.mpg

// split keyframe_input2 into smaller chunks
ffmpeg -i keyframe_input2.mpg -acodec copy -f segment -segment_time 0.3 -segment_list  s.m3u8 -vcodec copy -reset_timestamps 1 -map 0 split_input2-%d.mpg

// concatenate video according to the video files written in mylist.txt
ffmpeg -f concat -i mylist.txt -c copy output.mpg

当我尝试连接这些视频块时,错误被抛出,说缓冲区下溢,数据包大小太大。

这些是错误的部分。我不确定哪些错误引用哪个视频(input.mp4或input2.mov),但这就是我所拥有的:

[mpeg @ 0x7f972406ca00] Non-monotonous DTS in output stream 0:0; previous: 2953328, current: 2541459; changing to 2953329. This may result in incorrect timestamps in the output file.
[mpeg @ 0x7f972406ca00] Non-monotonous DTS in output stream 0:0; previous: 2953329, current: 2545059; changing to 2953330. This may result in incorrect timestamps in the output file.
[mpeg @ 0x7f972406ca00] Non-monotonous DTS in output stream 0:0; previous: 2953330, current: 2548659; changing to 2953331. This may result in incorrect timestamps in the output file.
[mpeg @ 0x7f972406ca00] Non-monotonous DTS in output stream 0:0; previous: 2953331, current: 2552259; changing to 2953332. This may result in incorrect timestamps in the output file.


[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=7973 size=8360
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=923 size=954
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=2538 size=7686
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=4579 size=7686
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=6620 size=7686
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=339 size=511
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=721 size=2766
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=2762 size=2766
[mpeg @ 0x7f972406ca00] buffer underflow st=0 bufi=988 size=1814

有专家知道为什么会这样吗?

0 个答案:

没有答案