问题描述
所以我尝试使用以下命令将2个视频文件与相同的编解码器相结合:
So I've tried using the following command to combine 2 video files with the same codec:
ffmpeg -i "concat:/home/mike/downloads/a1.mp4|/home/mike/downloads/a2.mp4" -c copy "/home/mike/downloads/output.mp4"
结果: output.mp4
仅包含来自 a1的视频。 MP4
。我也尝试了2个或更多的文件,但结果是一样的。这可能是什么原因?请帮助
The the result: output.mp4
only contains video from a1.mp4
. I also tried 2 or more file but the result is the same. What could be the possible cause for this? Please help
Mike
推荐答案
您不能连接 mp4
直接使用 concat协议
,因为格式不支持。这是针对 mpg
或 mpeg-ts
等等。
You cannot concatenate mp4
files directly with the concat protocol
because the format doesn't support it. This is intended for mpg
or mpeg-ts
and similar.
如果您通过以下格式之一,您可以执行此操作:
You can do it if you pass by one of those formats:
ffmpeg -i input1.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate1.ts
ffmpeg -i input2.mp4 -c copy -bsf:v h264_mp4toannexb -f mpegts intermediate2.ts
ffmpeg -i "concat:intermediate1.ts|intermediate2.ts" -c copy -bsf:a aac_adtstoasc output.mp4
替代方法是使用 concat demuxer
这是更灵活的(您仍然需要相同的编解码器的输入文件,但它可以使用不同的容器):
The alternative is to use the concat demuxer
which is more flexible (you still need the same codecs for the input files but it can use different containers):
ffmpeg -f concat -i mylist.txt -c copy output
其中 mylist .txt
是这样的:
# this is a comment
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'
这篇关于FFMPEG Concat协议不组合视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!