Programster's Blog

Tutorials focusing on Linux, programming, and open source

Strip Audio Tracks From an MKV with MKVToolNix

When watching an MKV video, the audio may default to a track we don't want, and are never going to use. Here, we will learn how to quickly strip an audio track from an MKV movie, without having to re-encode the video. Thus it takes very little time, and we do not reduce the video quality.

Installation

You will need to install the mkvtoolnix package. On Ubuntu, this can be done with the following command.

sudo apt-get install mkvtoolnix -y

Stripping Audio

One can find information about a video with the following command:

mkvmerge -i input.mkv

Look at the output to find out which ID(s) we want to keep and plug them into the following command:

mkvmerge \
-o [output filename] \
--atracks [audoio trak IDs] \
[input filename]

For example. To only keep track 2, we would use:

mkvmerge \
-o output.mkv \
--atracks 2 \
myvideo.mkv

But to keep audio tracks 1 and 2, we would use

mkvmerge \
-o output.mkv \
--atracks 1,2 \
myvideo.mkv

That's it! You should now have the video without the annoying default soundtrack, and you can now delete the original file.

References