Tool

Change the Default Audio and Subtitle Track and the Language Tag of an MKV

Sometimes you play a movie on a TV or a player and hear a language you did not want, or the subtitles turn on or off by themselves. MKV stores a ‘use this one by default’ mark and a language code for every track in its header, and players usually look at these values to pick the track to play first. Pick a file and the tool reads those marks and shows them. Choose the track you want as the default and it switches off the other tracks of the same type automatically, then saves a new file. The video is not re-encoded or remuxed, and the file never leaves this browser.

Where are the default flag and the language in the file?

MKV (Matroska) nests its elements in a structure called EBML. The track list lives in the Tracks element, and a single track is a TrackEntry. Inside it are the FlagDefault (the default-track mark; 1 means on), FlagForced (the forced mark) and Language (the language code, usually 3 letters such as kor or eng) elements. By the spec, the default of FlagDefault is 1 and the default of Language is eng, so if the element is missing altogether, it is read as that value. The track list sits apart from the Cluster elements that hold the video and audio data, so changing these values does not alter a single byte of the compressed video and audio.

That is why this tool reads only the Tracks part, not the whole file. When it edits, it does not change the length of any element and overwrites only the value in the same place (the default flag is one byte, 0 or 1, and the language is the same 3 letters in the same spot). If an element’s length changed, the indexes that point to later positions (SeekHead and Cues) would no longer line up, so the tool deliberately stays inside this range.

What this tool does

  • Read: shows each track’s type, codec, name, language, default, forced and enabled status. It tells you if a type has no default track or more than one.
  • Set the default track: pick the one audio or subtitle track to keep as the default and the other tracks of the same type are switched to ‘off’ automatically. Choose ‘turn off all’ to stop subtitles from turning on by themselves.
  • Change the language: choose from a list of common codes or type 3 letters yourself. und means the language is undetermined.
  • CRC-32 fix-up: if Tracks or a TrackEntry has a CRC-32 element and the value was valid, the tool recalculates the new value after the edit. A CRC that was already wrong is left alone.
  • Re-check after saving: it reads the new file back with the same code and writes on screen whether the file size, the track count, the changed values and the values that should not change (forced, enabled flag, codec) are as expected. This is a self-check by this tool, not the verdict of another program.
  • Commands: it builds the mkvpropedit command and the ffmpeg command for the same change.

How to use it

  1. Pick an MKV that plays the wrong track on your TV or player. First look at which tracks are on by default and whether the language marks are right.
  2. If you hear the wrong language: pick the track you want as the default under audio. If the language mark is wrong (for example, a Korean dub labeled eng), fix that track’s language too. If your player picks tracks by a ‘preferred language’ setting, the language code may matter more than the default mark.
  3. If subtitles turn on by themselves: under subtitles, choose ‘turn off the default on all subtitle tracks’. If you want a particular subtitle always on, pick that track as the default instead. The forced mark (FlagForced) is only read by this tool, not changed.
  4. Look at the re-check result for the saved file, then play it again on the TV or player that had the problem. Keep the original, check with the new file, and only then replace it.
  5. To pull subtitles out as a text file, use the MKV subtitle extractor; to drop unused tracks altogether and cut the file size, use the track picker; and if only the sound is missing on your TV, continue with the TV USB audio codec check.

How is it different from mkvpropedit?

mkvpropedit from MKVToolNix is the standard command-line tool for editing these values inside the file. The command this tool builds takes a form like --edit track:a2 --set flag-default=1, which selects a track by type plus number and sets a value. mkvpropedit is known to change only the values of the track you specify, so after turning on a new default track you have to write one more command yourself to turn off the previous default. This tool does both at once. On the other hand, mkvpropedit can insert new elements when it needs to, while this tool only overwrites the value of an element that already exists, at the same length. So it can do less, and for files it cannot handle you need mkvpropedit or mkvmerge.

ffmpeg can reach the same result with options like -disposition:a:0 -default and -metadata:s:a:1 language=kor, but that approach writes a new container, rewriting the entire file, which costs more time and disk on large files. The structure of containers and tracks is covered in Lesson 10-1.

Limits worth knowing

  • A value whose element is missing cannot be changed. A track with no FlagDefault element at all defaults to ‘on’ by the spec and cannot be turned off, and a track with no Language element cannot have a language set either. In that case the tool writes the reason on screen and blocks saving. Creating the element would change the length of the file, which is a job for mkvpropedit or mkvmerge.
  • Tracks with LanguageBCP47 do not get a language change. Recent versions of the spec have a BCP 47 language element separate from Language, and when it is present it is known to take priority. This tool does not edit that element, so changing Language alone might have no effect or leave the two values disagreeing; that is why it is blocked.
  • Player behavior was not tested. Whether a player or TV looks at the default flag or the language first, and whether the user’s preferred-language setting beats the default flag, differs by product, and this site has not checked it in a table. If the same track still plays after you change the values, that player may be using a different criterion.
  • Only MKV and WebM are read. MP4 has a different structure. Files whose track information sits after the clusters or has an undefined size, and files whose Tracks is larger than 8 MB, are not read. To move an MKV into MP4, see the MKV to MP4 converter.
  • It works by making a new file. A browser cannot edit the original in place, so it has you download a new file. If the file is very large, saving may fail depending on the browser or free disk space, and then an in-place tool like mkvpropedit is the right choice.
  • The EBML parser and the CRC-32 calculation were implemented by this site itself and have not been verified with MKVs from many authoring tools. The re-check after saving is a read-back with the same code, so for important files keep the original and open the result in a real player. This site does not send files or file names to a server.