MKV Logo

Change Default Tracks in MKV Files

Matroska (.mkv) is a container format with multiple audio and subtitle tracks. It depends on your language preferences as to what tracks are selected by default. I figured out a way to batch process whole directories to change the default tracks. MKVPropEdit is the command line tool required. You can download it as part of the MKVToolNix package.

Batch Processing

Run mmg.exe or use MKVInfo with the command line to find out your track numbers. Enter the settings you desire into a batch.bat file like the below example. Run the script and watch the magic happen. It’s best to run tests on a small directory to make sure it works properly. Nothing beats watching a computer do the work for you!

@echo off
for /f "tokens=*" %%G in ('dir *.mkv /a-d /b') do (
	C:\path\to\mkvpropedit.exe "%%G" --edit track:2 --set flag-default=0
	C:\path\to\mkvpropedit.exe "%%G" --edit track:3 --set flag-default=0
	C:\path\to\mkvpropedit.exe "%%G" --edit track:4 --set flag-default=1
	C:\path\to\mkvpropedit.exe "%%G" --edit track:5 --set flag-default=0
	echo.
)
pause

Flynsarmy has written a Linux version of the script.

#!/bin/bash
OIFS="$IFS"
IFS=$'\n'
for file in "/path/to/files/"*.mkv
do
	echo $file
	mkvpropedit "${file}" --edit track:2 --set flag-default=0
	mkvpropedit "${file}" --edit track:3 --set flag-default=0
	mkvpropedit "${file}" --edit track:4 --set flag-default=1
	mkvpropedit "${file}" --edit track:5 --set flag-default=0
done
IFS="$OIFS"