Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
813 views
in Technique[技术] by (71.8m points)

video - Howto merge two avi files using ffmpeg?

I'm unable to merge two avi videos together. google is full of below examples:

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.

but it doesn't work for me, the first video is converted and that's it.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You should look into the concat demux and concat protocol that was added in ffmpeg 1.1. Assuming the codecs are the same you create a file (example mylist.txt):

file '/path/here/file1.avi'
file '/path/here/file2.avi'
file '/path/here/file3.avi'

Then pass that file to ffmpeg

ffmpeg -f concat -i mylist.txt -c copy video_draft.avi

You can use this command to make the list:

ls *.avi | while read each; do echo "file '$each'" >> mylist.txt; done

The linked page has more advanced examples for dealing with issue like different codecs/formats.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...