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 $AUDIO_TRACK_ID \
  $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

Last updated: 24th February 2021
First published: 16th August 2018

This blog is created by Stuart Page

I'm a freelance web developer and technology consultant based in Surrey, UK, with over 10 years experience in web development, DevOps, Linux Administration, and IT solutions.

Need support with your infrastructure or web services?

Get in touch