2

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?

2

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

The -safe 0 above is not required if the paths are relative. The -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.

Source: https://trac.ffmpeg.org/wiki/Concatenate

  • Perhaps I wasen't clear enough. I'm looking for a way to merge chapters inside let's say name_of_movie.mkv into one chapter. I dont want to merge several movies together. I found an option in handbrake, which does exactly what I want but I'm still looking for a command line alternative, which could be used in a script. I find it a bit odd if you cannot do this on the command line. I'm using linux btw. PS4 is not able to play movies, which are split into chapters. Sorry for the missleading question and the use of loose definiton. Working with media files is a new territory for me. – Mikey Dec 10 '18 at 0:26
  • Can you explain without "chapter" term, just using files terms? And what you mean when told "merge chapters inside"? PS4 can play only specific codecs (for example h.264). File extension like mkv don't have a relation to codecs. – mature Dec 10 '18 at 8:24
  • It's possible to placess markers (starting points) at different points in the video so you can easily jump to them using the keyboard. Let's say I have a 1 h long video presentation and at 25.18 I bring up something interesting. I can place a marker at 25.18 and when I press some key on the keyboard I will get to 25.18. They are called chapter markers but people seem to refer to them as chapters. Now I have mkv movies, which have up to 4 chapter markers. I did a comparison between the mkv movies that worked on Ps4 ad the one's that didn't using handbrake and I noticed that the one's – Mikey Dec 10 '18 at 12:20
  • that didn't work had 4 chapters markers. The one's that worked had only one chapter marker. I would like one chapter marker instead of 4. – Mikey Dec 10 '18 at 12:23
  • 1
    You mean metadata markers: ffmpeg.org/ffmpeg-formats.html#Metadata-1 – mature Dec 10 '18 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.