You can merge a series of .avi files with ffmpeg using the concat filter. However, the concat filter requires that all inputs have the same streams (same codecs, same time base, etc.).
Here is an example of how you can do it (each video file should end in ..-01.avi
, ..-02.avi
, etc..):
First, create a file that contains the list of all your .avi files. You can do this manually, but if your files are named in a sequence like 01.avi, 02.avi, 03.avi, and so on, you can generate this list automatically using a bash command. Here's how you can do it:
for f in *.avi; do echo "file '$f'" >> mylist.txt; done
This will create a file mylist.txt
that contains a list of your .avi files in this format:
file '01.avi'
file '02.avi'
file '03.avi'
...
Then, you can use ffmpeg
to concatenate the .avi files listed in mylist.txt:
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.avi
This command tells ffmpeg to use the concat demuxer (-f concat)
, to read the input files from mylist.txt (-i mylist.txt
), and to copy the codec data without transcoding (-c copy
). The result will be written to output.avi
.
Please note that this method only works if all the .avi files have the same format and codec. If they differ, you will have to transcode them to a common format/codec before concatenating.
Also, the -safe 0 option is not an instruction to ignore safety, but is required when the file paths are relative, which is likely the case if you're using the command above to generate mylist.txt.