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

This solved the matter: https://stackoverflow.com/a/22324018/5014767

melt is a great command line utility for this. Here is the page

Edit from comments: The command which solved my problem was this melt {input-sequence} -consumer avformat:{output-name} acodec=libmp3lame vcodec=libx264