How to Change Default Audio Track in MKV with FFmpeg

This guide explains how to change the default audio track flag in an MKV (Matroska) video file using FFmpeg. By utilizing FFmpeg’s stream disposition metadata, you can easily define which audio track plays automatically when the file is opened in a media player. This process is performed without re-encoding the video or audio streams, meaning it runs almost instantly and preserves the original quality of your media.

To change the default audio track, you must use the -disposition option in FFmpeg. This flag allows you to enable or disable the default property on specific audio streams.

The FFmpeg Command

Here is the standard command to make the second audio stream the default, while removing the default status from the first audio stream:

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

Command Breakdown

Identifying Your Audio Stream Indexes

Before running the command, you need to know which audio streams correspond to which index. You can view the stream layout of your file using ffprobe:

ffprobe input.mkv

In the output, look for the audio streams. FFmpeg indexes audio streams separately starting at 0. For example: * Stream #0:1: Audio: dts ... represents the first audio stream (a:0). * Stream #0:2: Audio: ac3 ... represents the second audio stream (a:1).

Adjust the numbers in your -disposition:a:X parameters based on the specific stream indexes you wish to modify.