How would you merge chapters in mkv files into one chapter? I've only found threads about adding, removing and splitting chapters. I'm looking for a command line tool. Can ffmpeg be used for this?
In most cases ffmeg only can help.
Create a file mylist.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 '/path/to/file1.mkv' file '/path/to/file2.mkv' file '/path/to/file3.mkv'
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 mylist.txt -c copy output.mkv
-safe 0 above is not required if the paths are relative.
-c copy try concat files without re-encoding. Try remove this params if something will wrong. I mean mkv is a just container can included inside any codecs like h.264 (MPEG-4 AVC), MPEG-2, VC-1, MPEG-2, mpeg-4 / Xvid / DivX.. It need to know which one encoder\decoder codec(s) installed or not with your ffmpeg. Need know exactly or just try. But this is another question. Let's assume that your ffmpeg install fully support your current mkv's codecs.