ffmpeg concatenate mkv/mp4

add all your files to a text file, say merge.txt that needs to be merged together. The file names can be full path or just the file names. If you just go with filenames then it is simpler to keep this merge.txt next to the files to be merged.

file a.mkv
file b.mkv
file c.mkv

cmd to merge files:

ffmpeg -f concat -safe 0 -i merge.txt -c copy result.mkv

If you place merge.txt file next to the files to be merged then -safe 0 is not required.

Note: ffmpeg can merge files of different types- but it best if you merge files that have been encoded with same encoder and same settings.

further details on ffmpeg documentation here: https://trac.ffmpeg.org/wiki/Concatenate