You can use mkvmerge
from the MKVToolNix suite to remove unwanted audio tracks while keeping only the ones you need. Here’s how:
Step 1: Identify the Tracks in the MKV File
Run the following command to list all the tracks in the MKV file and identify the track numbers:
mkvmerge -i input.mkv
You’ll see output like this:
File 'input.mkv': container: Matroska
Track ID 0: video (V_MPEG4/ISO/AVC)
Track ID 1: audio (A_AC3) [English]
Track ID 2: audio (A_AC3) [French]
Track ID 3: audio (A_AAC) [Spanish]
Track ID 4: audio (A_AAC) [German]
...
Note the track IDs of the two audio tracks you want to keep (e.g., 1 and 3).
Step 2: Extract the Desired Tracks
To keep specific tracks, use the --audio-tracks
option with their IDs:
mkvmerge -o output.mkv --audio-tracks 1,3 input.mkv
This command will create a new MKV file (output.mkv
) with only the video and the specified audio tracks.
Step 3: Include Video and Subtitle Tracks (if needed)
By default, mkvmerge
includes video and subtitle tracks along with the specified audio tracks. If you need to specify all the tracks explicitly (e.g., keep track 0 for video, 1 and 3 for audio, and specific subtitles), you can do this:
mkvmerge -o output.mkv --tracks 0,1,3,5 input.mkv
Here:
0
is the video track ID.1
and3
are the audio tracks you want to keep.5
is a subtitle track ID (if you wish to keep it).
Step 4: Verify the Output
Check the new file to ensure it contains the correct tracks:
mkvmerge -i output.mkv
Automating Track Selection
If you often work with MKV files with many audio tracks, you can use a script to automate selecting specific language tracks based on language codes (--language
option) or track properties. Let me know if you’d like help creating such a script!