(FFmpeg) How to Concatenate Multiple Videos?

Using concat with a txt file has one catch, all the MP4s must have the exact codec, framerate, resolution, etc. An example text file is shown below (file.txt): 

file 'input0.mp4'
file 'input1.mp4'
file 'input2.mp4'

Then run the following command to load the txt file to create a single file from the list:

  $ ffmpeg -f concat -i file.txt -c copy -fflags +genpts full.mp4   

But how can you join multiple MP4 files that are not exactly the same resolution, codec or framerates? A different method of concat is required, as seen in the example below:

 $ ffmpeg -i input0.mp4 -i input1.mp4 -i input2.mp4 -filter_complex "[0:v] [0:a] [1:v] [1:a] [2:v] [2:a] concat=n=3:v=1:a=1 [v] [a]" -map "[v]" -map "[a]" output.mp4
concat
	Indicates the concat filter name

n
	Indicates the number of segments or input files

v
	Indicates the number of output video streams

a
	Indicates the number of output audio streams

Related Posts