How to merge multiple (more than two) videos on Ubuntu?

I am using mkvmerge to join multiple MP4 files into single one:

mkvmerge -o outfile.mkv infile_01.mp4 \+ infile_02.mp4 \+ infile_03.mp4

You can do it using ffmpeg:

ffmpeg -i concat:"input1.mp4|input2.mp4" output.mp4

reference and more info


Create a file files.txt with all the files you want to have concatenated in the following form (lines starting with a # are ignored):

# this is a comment
file 'file1.mp4'
file '/path/to/file2.mp4'
file 'file3.mp4'

Note that these can be either relative or absolute paths. Then you can stream copy or re-encode your files:

ffmpeg -f concat -safe 0 -i files.txt -c copy output.mp4