MKVToolnix erases chapter markers when merging file

Hello!
I tried to register on Gitlab to submit an issue, but those whores demanded me to surrender my card and phone thus invading my privacy. So I’m posting it here instead.
I’ve just tried to merge a single mkv file from 2 mkv files. I wanted to take the video track from first file and everything else from second file. Among everything else the file has chapter markers, which include one group of markers in English (prefix en:) and another in Russian (prefix ru:). I launched the merging and it went well except one thing - the Russian markers disappeared. I’ve tried using --disable-language-ietf option, but it didn’t help. The source file which has both groups was created with an old version of the tool several years ago.
I’m using Debian 12 x64 with MKVT 74.0.0.

Welcome!

Wild guess: there are chapters in both files, and in both files the same unique IDs are used for the chapters. In such a case mkvmerge will consider them to be the result of a splitting operation & merge their start & end timestamps, discarding everything else from the second file.

As a workaround modify the chapters in one of the files & give them really unique IDs (at least unique to the two files in question) & try again.

The guess is partly wrong - the markers are contained only in one of the files. However in two groups of markers in the file that contains them they indeed have the same IDs (says chapter editor) - the English marker and the corresponding Russian one.
Obviously I don’t want to rewrite these IDs by hand. So how do I do this automatically?

Can you please save the chapters to an XML file & upload it somewhere, e.g. to my file server? I’d like to take a look at it. Thanks.

Sure. Here goes. The folder is named 124.

Thanks. Yeah… this isn’t how adding multiple names to single chapter entries works. It might work in some applications by relying on them to merge editions with identical unique IDs & merging chapter atoms with identical unique IDs, but that isn’t what the specs say you should do.

The canonical way (both according to the specs & how MKVToolNix handles them) is to have one ChapterAtom with multiple ChapterDisplay beneath it, each ChapterDisplay containing a different language.

For example, this is how things look at the moment:

<?xml version="1.0"?>
<!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> -->
<Chapters>
  <EditionEntry>
    <EditionUID>10792683537392517029</EditionUID>
    <ChapterAtom>
      <ChapterUID>8733525442029095349</ChapterUID>
      <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>
      <ChapterDisplay>
        <ChapterString>The Beginning</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
        <ChapLanguageIETF>en</ChapLanguageIETF>
      </ChapterDisplay>
    </ChapterAtom>
  </EditionEntry>
  <EditionEntry>
    <EditionUID>10792683537392517029</EditionUID>
    <ChapterAtom>
      <ChapterUID>8733525442029095349</ChapterUID>
      <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>
      <ChapterDisplay>
        <ChapterString>Начало</ChapterString>
        <ChapterLanguage>rus</ChapterLanguage>
        <ChapLanguageIETF>ru</ChapLanguageIETF>
      </ChapterDisplay>
    </ChapterAtom>
  </EditionEntry>
</Chapters>

And here’s how it should look:

<?xml version="1.0"?>
<!-- <!DOCTYPE Chapters SYSTEM "matroskachapters.dtd"> -->
<Chapters>
  <EditionEntry>
    <EditionUID>10792683537392517029</EditionUID>
    <ChapterAtom>
      <ChapterUID>8733525442029095349</ChapterUID>
      <ChapterTimeStart>00:00:00.000000000</ChapterTimeStart>
      <ChapterDisplay>
        <ChapterString>The Beginning</ChapterString>
        <ChapterLanguage>eng</ChapterLanguage>
        <ChapLanguageIETF>en</ChapLanguageIETF>
      </ChapterDisplay>
      <ChapterDisplay>
        <ChapterString>Начало</ChapterString>
        <ChapterLanguage>rus</ChapterLanguage>
        <ChapLanguageIETF>ru</ChapLanguageIETF>
      </ChapterDisplay>
    </ChapterAtom>
  </EditionEntry>
</Chapters>

I’ve attempted to fix the whole file for you. You can download it here.

1 Like

Thank you! I’ll try to bake this xml into the output now.
As for the spec stuff you talk about, I didn’t get that deep when I made the old file several years ago. That is, I didn’t write chapters in XML manually looking at the specification. I just wrote them in MKVT and baked into the file. So the way it is done was done by MKVT of that old version. MediaInfo says it was 24.0.0.

Well every version of MKVToolNix always allowed you to create chapter atoms that have multiple names with different languages. However, it has always been (and is still possible) to create files such as yours in the GUI by fiddling with the UIDs yourself, or by copy-pasting inside the XML file, or by duplicating entries in the chapter editor. The chapter editor doesn’t try to prevent you from shooting yourself in the foot much.

That being said, it’s also possible that there was a bug way back when. I don’t remember anything like this, but that doesn’t make it impossible.

It was 5 years ago, so I can’t remember what exactly I did.
But your edit works! I’ve baked it into the file and now both languages show up in MediaInfo. They also do in the players, although there’s a strange thing - both SMPlayer and MPC-BE show chapters only in one language (one in Russian and another in English) without an option to switch them. Do you happen to know whether there is such an option in any player at all?

No, sorry. I don’t use chapters with multiple languages for my own files & have no experience with how players present them to the user.