1. Home
  2. Linux

How To Extract Information From MKVs On Linux

Many people love MKV because of how it can compress large amounts of raw audio and video footage into a small package. Another great feature of MKV is how easy it is to modify the contents of it. One of the best tools on Linux that can extract information from MKVs is MKVToolNix.

Install MKVToolNix

Installing the MKVToolNix apps gives users a great set of GUI and command-line programs to easily modify, inspect and tinker with MKVs. Choose your operating system below and follow the commands to get the software working.

Ubuntu

As of now, the MKVToolNix application set supports Ubuntu 16.04, 17.10 and 18.04. To get it working, you’ll need to edit the Ubuntu software sources file manually. The reason you’ll need to edit this file is that the developer of MKVToolNix doesn’t currently have a custom PPA available. Still, adding software repositories in this way is hardly that different.

To add the new software source, open up a terminal window and use the Nano text editor to edit the /etc/apt/sources.list file on your Ubuntu PC.

sudo nano /etc/apt/sources.list

In the sources file, press the down arrow key on the keyboard to move all the way to the bottom of the file. Once there, add a new comment. Don’t skip the comment part! If you fail to add a comment, you may forget what this software repository does at a later time.

# MKVToolNix Ubuntu repo

After adding the comment, it’s time to add the software source. Choose your version of Ubuntu, and paste the code in Nano.

Ubuntu 16.04

deb https://mkvtoolnix.download/ubuntu/ xenial main
deb-src https://mkvtoolnix.download/ubuntu/ xenial main

Ubuntu 17.10

deb https://mkvtoolnix.download/ubuntu/ artful main
deb-src https://mkvtoolnix.download/ubuntu/ artful main

Ubuntu 18.04
deb https://mkvtoolnix.download/ubuntu/ bionic main
deb-src https://mkvtoolnix.download/ubuntu/ bionic main

Now that the new software source is added to Ubuntu, you’ll need to add the signed GPG key as well, so that Ubuntu will allow the software from this new repository to install on your system. If you skip this step, MKVToolNix will not work.

wget -q -O - https://mkvtoolnix.download/gpg-pub-moritzbunkus.txt | sudo apt-key add -

Finally, after the modifications are complete, it’s time to refresh Ubuntu, install some upgrades and get MKVToolNix working.

sudo apt update

sudo apt upgrade -y

sudo apt install mkvtoolnix mkvtoolnix-gui

Note: if the apt update command fails to install, you’ll need first to do this:

sudo apt install apt-transport-https

After apt-transport-https is working, try installing MKVToolNix again.

Debian

Installing the MKVToolNix set of applications on Debian is very similar to Ubuntu, as the developer has chosen to distribute the software via repositories. To get the app working on Debian, open up a terminal and use the Nano text editor to edit the /etc/apt/sources.list file.

Note: MKVToolNix officially supports Debian 9 Stable and Debian 8.

sudo nano /etc/apt/sources.list

Inside the sources file, use the arrow keys and move all the way to the bottom of the file. Press # to add a new comment line.

# MKVToolNix Debian Repo

Now that the comment line is in the sources file, it’s safe to add the software repository URLs tool.

Debian 9 

deb https://mkvtoolnix.download/debian/ stretch main
deb-src https://mkvtoolnix.download/debian/ stretch main

Debian 8

deb https://mkvtoolnix.download/debian/ jessie main
deb-src https://mkvtoolnix.download/debian/ jessie main

After adding the new software source, use the wget command to add the GPG key.

wget -q -O - https://mkvtoolnix.download/gpg-pub-moritzbunkus.txt | sudo apt-key add -

Use the update and upgrade commands to refresh and install updates on Debian.

sudo apt-get update

sudo apt-get upgrade -y

Lastly, install the MKVToolNix apps:

sudo apt-get install mkvtoolnix mkvtoolnix-gui

Arch Linux

All of the MKVToolNix applications are readily available in the main Arch Linux software sources. To install them, open up a terminal and use the Pacman, package manager.

pacman -S mkvtoolnix-cli mkvtoolnix-gui

Fedora

MKVToolNix supports Fedora from versions 26 to 28 (the current release). To install the software, you’ll need to add the official software repository. Using dnf, grab this RPM file and install it.

sudo dnf install https://mkvtoolnix.download/fedora/bunkus-org-repo-2-3.noarch.rpm -y

With the new MKVToolNix repo active on Fedora, use dnf to install the program.

sudo dnf install mkvtoolnix

OpenSUSE

OpenSUSE has MKVToolNix available via a third-party software repository. To add the repo, open up a terminal and execute the following commands.

Note: MKVToolNix, as of now, only supports OpenSUSE 42.3 Leap.

wget https://mkvtoolnix.download/gpg-pub-bunkusorg-rpm-signing.txt
sudo rpmkeys --import gpg-pub-bunkusorg-rpm-signing.txt
sudo zypper addrepo --refresh https://mkvtoolnix.download/opensuse/42.3/ MKVToolNix

When everything is enabled, install the software using Zypper.

sudo zypper install mkvtoolnix

Using MKVToolNix

MKVToolNix is very useful and is quick to import or export data to an MKV container. If you’re looking to obtain audio, video or subtitles (SRT) from inside an MKV, here’s what to do. First, open up the GUI app, by searching for “MKVToolNix” in your application menu.

Once open, click on “multiplexer.” In the multiplexer window, look for the “Add source files” button and click on it. Using the file browser, locate and add an MKV file to the program.

The program will scan and add the MKV to the program. It’ll show the exact contents of the file.

Extract Audio

To extract audio from the MKV directly, look under “tracks, chapters and tags.” Uncheck boxes next to the video, the subtitle track (as well as anything else that shows up).

Locate the default audio track and ensure that the box next to it is checked.

Click the “start multiplexing button” to start the extraction. The audio file will be right next to the MKV file you’ve imported.

Extract Video

Extracting video from MKV files works the same way as the instructions for exporting audio. Start off by adding a new MKV file. Next, uncheck the boxes next to the audio track and subtitle track.

Check the box next to the default video track. When everything looks good, click the “start multiplexing” button. Soon after, the raw video track will extract to the same folder that the source MKV video file is in on your PC.

Extract Subtitles

Need to export a subtitle track from an MKV? Start off by adding the file to MKVToolsNix. Uncheck the boxes near the default video track, audio track and everything else. Be sure to keep the box checked next to any subtitle tracks you want to take out of the MKV container file.

Start the extraction process by clicking “start multiplexing”. The raw subtitle file will be located in the same folder as the imported MKV file.

Leave a comment