Question about correct command line syntax for mkvmerge under special circumstances

Dear all,

it seems that I am encountering weird Blu-Ray playlists from time to time. Today I have met the following situation (to make the problem clear, I have simplified it):

I have three m2ts files that I would like to convert to MKV. The files are named 1.m2ts, 2.m2ts and 3.m2ts. Each of these files contains a video track with track ID 0. In addition, 1.m2ts and 3.m2ts contain a subtitle track with track ID1, but 2.m2ts does not contain a subtitle track.

Originally, I had a command line like that:

mkvmerge ... --append-to 1:0:0:0,2:0:1:0,1:1:0:1,2:1:1:1 ... -d 0 -s 1 1.m2ts -d 0 -s 1 +2.m2ts -d 0 -s 1 +3.m2ts

This produced a warning:

Warning: '2.m2ts': A track with the ID 1 was requested but not found in the file. The corresponding option will be ignored.

I am totally understanding this warning, and it’s great that this is not treated as an error, but that the offending option is simply ignored instead.

However, there was also an error:

Error: The file no. 2 ('2.m2ts') does not contain a track with the ID 1, or that track is not to be copied. The argument for '--append-to' was invalid.

Again, I understand the error message. But this time, I don’t know how to work around it. What would be the correct value for --append-to in this case? Do I need to append the subtitle track in the third file to the subtitle track in the first file? The command line then perhaps would be

mkvmerge ... --append-to 1:0:0:0,2:0:1:0,2:1:0:1 ... -d 0 -s 1 1.m2ts -d 0 +2.m2ts -d 0 -s 1 +3.m2ts

Thank you very much in advance, and best regards,


Unfortunately mkvmerge requires that all appended files have all the tracks that should be in the output file. If your middle file doesn’t have a subtitle track, then you must not mux the superfluous subtitle tracks from the other files. mkvmerge simply cannot treat the missing subtitle track in the middle as being present but having no content whatsoever.

What you can try, though, is a multi-step process with the goal of creating an intermediate file consisting of the first two files including the subtitle track from the first file. You might then be able to append the third file to said intermediate file.

So how would that look like?

First, create an intermediate file without the subtitle track:

mkvmerge -o intermediate_no_subs.mkv -d 0 -S 1.m2ts -d 0 +2.m2ts

Next merge the intermediate with the subtitle track from the first file:

mkvmerge -o intermediate_with_subs.mkv intermediate_no_subs.mkv -A -V -s 1 1.m2ts

Now append the third file to the second intermediate file. Note that you have to select a different append mode, otherwise mkvmerge will try to place the subtitle content from the third file where the subtitle content from the intermediate file ends — meaning it won’t be delayed properly:

mkvmerge -o final.mkv intermediate_with_subs.mkv -d 0 -s 1 +3.m2ts --append-mode file

This is completely untested.

Wow, that answer was fast! Thank you very much for the thorough explanation and for the workaround.

I’ll try it, and if it works, I’ll have to automate it to get it implemented in a custom program I’m currently working on (the question was arising when testing that software).

Thank you very much also for the hint regarding --append-mode; I surely would have missed it. But in this case, the append mode is not important because I am using external timestamp files.

As an anecdote, 2.m2ts from the example is not only missing the subtitle track, but all audio tracks as well; it contains only the video track. I have left that away in my examples for clarity. Sometimes I believe playlists are constructed like that by intention just to confuse us.

Thank you very much again, and best regards,