2 mkvextract wrong track mkvinfo mkvmerge track IDs wrong
Moritz Bunkus edited this page 2016-02-24 21:23:16 +01:00

mkvextract extracts the wrong track! mkvmerge doesn't set options! And mkvinfo's track IDs do not match mkvextract's or mkvmerge's!

The problem

There's something wrong -- I tell mkvextract to extract a track but it extracts a different one.

The answer

You're using the wrong numbers when executing mkvmerge. Here's you can find out the right numbers.

First of all, there's a misconception about three different terms: track numbers, track UIDs (track unique IDs) and track IDs. The former two, track numbers and track UIDs, are fields stored in the track headers of a Matroska file. The corresponding elements are called "TrackNumber" and "TrackUID" in the Matroska specs.

The latter ones, track IDs, are IDs assigned by mkvmerge and mkvextract upon program invocation. Those IDs are not actually present in the file, and they're only valid within the same version of the MKVToolNix tool family. The order and numbering scheme of these IDs is also subject to change.

Earlier versions of mkvmerge used to assign track IDs that usually equaled the track's "TrackNumber" element. Therefore users were using those numbers in order to correlate the output of mkvinfo (or even third party tools like MediaInfo) with the input of mkvextract -- which is wrong. In order to find out the track IDs that mkvmerge and mkvextract use one is suposed to execute mkvmerge in identification mode:

mkvmerge --identify yourfile.mkv or, for more information, mkvmerge --identify-verbose yourfile.mkv

The only guarantee that I make is that the same version of mkvmerge and mkvextract will use the same track IDs. Unfortunately there were a few releases that contained changes and bugs that caused confusion:

  • In v5.2.0 the numbering scheme that mkvmerge uses for Matroska and MP4 files was changed in order to fix a bug. Unfortunately mkvextract wasn't updated to match.
  • In v5.2.1 mkvextract was partially fixed: track extraction worked, but timecode extraction was still using the wrong track IDs.
  • With release v5.3.0 mkvextract's timecode extraction was fixed.

In order to simplify correlating mkvmerge's track IDs and mkvinfo's output mkvmerge will output the track's UID in verbose identification mode along with a few other new header fields starting with release v5.3.0.

Categories: extraction, metadata