Set Default Audio Track in MKV with FFmpeg

This guide provides a quick overview and step-by-step instructions on how to set a specific audio track as the default in a multi-track MKV file using FFmpeg on Linux. When a video contains multiple audio languages or commentary tracks, media players look for a specific metadata flag to determine which one to play automatically. By utilizing FFmpeg’s stream mapping and metadata disposition tools, you can easily change this default target without re-encoding the video, saving both time and quality.

Step 1: Identify the Audio Stream Index

Before changing the default track, you need to know the index number of the audio stream you want to target. Run the following command to inspect your MKV file:

ffmpeg -i input.mkv

Look at the output lines that start with Stream #0:. You will see video streams, audio streams, and subtitles. Note the index of the audio track you want to make the default (for example, Stream #0:2 means the index is 2).

Step 2: Set the Default Flag

To set your chosen audio track as the default, you will use the -disposition flag. The following command copies all video, audio, and subtitle streams without re-encoding them (-c copy), turns off the default flag for all audio streams, and then turns it on specifically for your chosen stream.

Assuming you want stream index 2 to be the default audio track, run:

ffmpeg -i input.mkv -map 0 -c copy -disposition:a 0 -disposition:a:2 default output.mkv

Command Breakdown

Verifying the Changes

Once the command finishes running, you can verify that the metadata was applied correctly by inspecting the new file:

ffmpeg -i output.mkv

In the stream layout output, you should now see (default) next to the specific audio stream you targeted, ensuring that media players like VLC or MPV will automatically select it upon playback.