Monday, November 30, 2020

Concatenate two MP4 files using ffmpeg

Note to self: to concatenate two (or more) MP4 files using ffmpeg, using the following.

First, create a list of files to concatenate:
echo file file1.mp4 >  mylist.txt
echo file file2.mp4 >> mylist.txt
echo file file3.mp4 >> mylist.txt


The contents of mylist.txt should be something like this:
file file1.mp4
file file2.mp4
file file3.mp4 
For long filenames, I think they can be included within single quotation marks:
file 'file name 1.mp4'
file 'file name 2.mp4'
file 'file name 3.mp4' 

Then, run ffmpeg to concatenate the list of files:
ffmpeg -f concat -i mylist.txt -c copy output.mp4

The list of files should contain the files to be joined together in order.

No comments: