Change the default audio/subtitle tracks in a .mkv file

Install mkvtoolnix

1sudo apt install mkvtoolnix mkvtoolnix-gui

Then use the mkvpropedit command

1mkvpropedit foo.mkv --edit track:a1 --set flag-default=1 --edit track:s1 --set flag-default=1

To edit all mkv files in a directory at once

1find . -name "*.mkv" -exec mkvpropedit {} --edit track:a1 --set flag-default=1 --edit track:s1 --set flag-default=1 \;

Notes:

  • use mkvinfo filename.mkv to see the tracks and which ones are default
  • find . -name "*.mkv" -exec ... \; means find all .mkv files and execute an operation … on them
  • track:a1 seems to be the first audio track
  • track:s1 seems to be the first subtitle track
  • Seems like flag-default=1 makes it the default track?
  • Note that if the other tracks do NOT have flag default already set to 0, that needs to be done through the above cmd line since mkvpropedit does not automatically set other tracks to default to 0 when some track is set to 1. See https://manpages.ubuntu.com/manpages/jammy/en/man1/mkvpropedit.1.html

Reference