After using mkvpropedit or the GUI's header or chapter editors all track information has vanished
You use mkvpropedit or the GUI's header editor on a file and change some pieces of information. Afterwards you use a different application or hardware device for playing that file but it won't play, e.g. no track information is found anymore.
The same applies for similar situations, e.g. when you replace chapters and they're not found anymore afterwards.
Matroska is a flexible file format. It allows several pieces of information to be located in different places. Usually track information is kept at the start of the file (that's what mkvmerge does), as is other important information like the chapters. Yet some elements like the index are kept at the end by default.
However, this is not mandatory. It is perfectly valid to write track information, chapters and tags at the end of the whole file.
In order to let a player find those pieces of information the Matroska file format provides certain index elements called the »meta seek« elements (or just the »meta seek«). These do nothing but tell the player where it can find important element X in the file. As there is only a very limited number of important elements that are indexed in the meta seek elements they stay pretty small, usually not even a hundred bytes.
One important rule is that meta seek elements can point to other meta seek elements which in turn point to the important elements like chapter and track information. Therefore players must read meta seek elements recursively.
There are situations in which both mkvpropedit and the GUI's header and chapter editors need to relocate such pieces of information from the start of the file to the end of the file. This happens when they need to write a lot more information than they've initially read from that place (e.g. when you add a long list of chapters and there were previously no chapters at all). In that case the programs will write the information at the end of the file and invalidate the old information stored at the beginning.
This leads to three common scenarios:
- Normal mode: only one meta seek element at the beginning of the file. All important information like tracks and chapters are located at the beginning as well. This is the situation after you've muxed something with mkvmerge. It can also still be the situation after you've changed the file with e.g. mkvpropedit if mkvpropedit had enough room to write its changes at the beginning.
- Apply changes with e.g. mkvpropedit with insufficient free space at the beginning of the file. In this case mkvpropedit writes the information at the end and updates the single meta seek element at the beginning of the file. Still only one meta seek element pointing directly to the important elements.
- A situation even worse than 2.: now mkvpropedit doesn't even have enough space for adding that entry in the meta seek element. In this case mkvpropedit will also write a meta seek element at the end of the file and let the meta seek element at the beginning point to the meta seek element at the end. Only the meta seek element at the end will point to the other important element.
This leads to the following algorithm that all applications reading Matroska files properly have to support:
- Start reading at the beginning of the file up to the first cluster. Remember the positions of the important elements found so far.
- Recursively read all meta seek elements starting with the one(s) found in step 1. Remember all positions of important elements pointed to from the meta seek elements.
- Read all important elements found in steps 1. and 2. keeping in mind that elements found in 2. may point to the same elements found in 1.
Do note, though, that in mkvinfo's default processing mkvinfo will not find those track headers. In order to understand why please see this FAQ entry.
If you find yourself in this situation, you'll have to re-mux the affected files with
mkvmerge / the GUI's multiplexer tool. You don't have to change anything, to set any special option — a simple re-mux suffices (e.g.
mkvmerge -o out.mkv in.mkv).