如何使用ffmpeg合并两个avi文件?

tes*_*mus 22 video merge join ffmpeg cat

我无法将两个avi视频合并在一起.谷歌充满了以下例子:

cat file1.avi file2.avi file3.avi > video_draft.avi
after appending the data together using cat above, you need to re-index the draft movie like this:

mencoder video_draft.avi -o video_final.avi -forceidx -ovc copy -oac copy
Now you're video_final.avi file will be right to go.
Run Code Online (Sandbox Code Playgroud)

但它对我不起作用,第一个视频被转换,就是这样.

cwg*_*gem 59

您应该查看ffmpeg 1.1中添加的concat demux和concat协议.假设编解码器是相同的,您创建一个文件(示例mylist.txt):

file '/path/here/file1.avi'
file '/path/here/file2.avi'
file '/path/here/file3.avi'
Run Code Online (Sandbox Code Playgroud)

然后将该文件传递给ffmpeg

ffmpeg -f concat -i mylist.txt -c copy video_draft.avi
Run Code Online (Sandbox Code Playgroud)

您可以使用此命令来制作列表:

ls *.avi | while read each; do echo "file '$each'" >> mylist.txt; done
Run Code Online (Sandbox Code Playgroud)

链接页面有更高级的示例,用于处理不同编解码器/格式等问题.

  • 此过程给我以下错误:`未知的输入或输出格式:concat` (3认同)
  • 将ffmpeg更新到最新版本以避免`未知输入或输出格式:concat` (2认同)

小智 16

您可以使用此单个命令行:

ffmpeg -i "concat:input1.avi|input2.avi|input3.avi" -c copy output.avi
Run Code Online (Sandbox Code Playgroud)