brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mkvpropedit changes track language and default flag without remuxing

CLI
~/tips/tip-mkvpropedit-set-language

mkvpropedit movie.mkv --edit track:a1 --set language=eng

Edits the language or default flag of an MKV track in place, in a fraction of a second.

A rip with an audio track labeled “und” makes players pick the wrong one. Rewriting a whole 8 GB file just to fix a label is a waste. mkvpropedit, part of MKVToolNix, edits the header only.

mkvpropedit movie.mkv --edit track:a1 --set language=eng

--edit track:a1 selects the first audio track. The letters are a for audio, s for subtitles and v for video, and numbering starts at 1. Everything after it applies to that track until the next --edit, so you can chain several in one call:

mkvpropedit movie.mkv \
  --edit track:a1 --set language=eng --set flag-default=1 \
  --edit track:a2 --set language=nld --set flag-default=0

The file is modified in place, with no complete remux. That makes it fast, and it also means there is no undo, so copy files you care about first.

One catch: setting flag-default=1 on a track does not clear the flag on the others. If two tracks claim to be the default, set the old one to 0 yourself, as in the example. Run mkvmerge --identify movie.mkv first to see which track is which.

The selector has other forms too. The docs describe track:=UID to pick a track by its track UID and track:@number to pick it by track number, both readable from mkvinfo. A plain number such as track:2 means the second track of any type.

Two details on the language itself. Setting language updates both the newer IETF language element and the legacy one, while language-ietf touches only the IETF one. The docs also say the tool exits with code 1 when it issued warnings but still made the change, so check the warnings and the resulting file in a script.

Further reading: mkvpropedit documentation

More CLI tips printf 'GET /\r\n' | hexdump -C hexdump -C -s 512 -n 64 disk.img wget --limit-rate=2m https://example.com/big-file.iso wget --spider https://example.com/file.zip rg 'apiKey' -g '!*.min.js' -g '!package-lock.json' All CLI tips (46) All topics

Link