MKVToolNix—Matroska tools for Linux/Unix

I use Linux Mint/Ubuntu (Debian), always an LTS version, so this is always done from that point of view.

Table of Contents

Installing/Updating MKVToolNix
Step 1: Downloads
MKVToolNix—Matroska tools for Linux/Unix Documentation (on-line man pages)

MKVToolNix is a set of tools to create, alter and inspect Matroska files under Linux, other Unices and Windows. The MKV part of the title refers to Matroska.

These are companions to MakeMKV. Please see my notes on that page.

Installing/Updating MKVToolNix

Step 1: Downloads

There is nothing to download per se.

Step 2: apt-get update and add essential packages

  1. Get the public GPG key:
    russ@gondolin ~ $ wget -q -O - https://mkvtoolnix.download/gpg-pub-moritzbunkus.txt | sudo apt-key add -
    
  2. Determine which Debian version (because there are 3 supported as I write this):
    russ@gondolin ~ $ cat /etc/debian_version
    stretch/sid
    
  3. Create /etc/apt/sources.list.d/mkvtoolnix.list and the correct Debian lines to it:
    deb https://mkvtoolnix.download/debian/ stretch main
    deb-src https://mkvtoolnix.download/debian/ stretch main
  4. Do update, which will include using the apt contents you just added in /etc/sources.list.d, then do the install:
    russ@gondolin ~ $ sudo apt update
    russ@gondolin ~ $ sudo apt install mkvtoolnix mkvtoolnix-gui
    
  5. If the command above fails, ensure that you have installed the apt HTTPs transport:
    russ@gondolin ~ $ sudo apt-get install apt-transport-https
    
  6. You may get unmet dependencies; check the versions you do have:
    russ@gondolin ~ $ sudo apt install mkvtoolnix mkvtoolnix-gui
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Some packages could not be installed. This may mean that you have requested an impossible situation
    or if you are using the unstable distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    
    The following packages have unmet dependencies:
     mkvtoolnix : Depends: libboost-filesystem1.62.0 but it is not installable
                  Depends: libboost-regex1.62.0 but it is not installable
                  Depends: libboost-system1.62.0 but it is not installable
     mkvtoolnix-gui : Depends: libboost-filesystem1.62.0 but it is not installable
                      Depends: libboost-regex1.62.0 but it is not installable
                      Depends: libboost-system1.62.0 but it is not installable
                      Depends: libqt5core5a (>= 5.7.0) but 5.5.1+dfsg-16ubuntu7.5 is to be installed
                      Depends: libqt5multimedia5 (>= 5.6.0~beta) but 5.5.1-4ubuntu2 is to be installed
    E: Unable to correct problems, you have held broken packages.
    russ@gondolin ~ $ dpkg --list | grep [b]oost
    ii  libboost-date-time1.58.0:amd64   1.58.0+dfsg-5ubuntu3.1   amd64    set of date-time libraries based on generic programming concepts
    
    Basically, this means that you cannot use Linux Mint because it's behind on boost. You'll have to wait until this situation changes. In my experience, you'll wait until the cows come home and still not get them. You can undertake to solve this, but you risk destabilizing your system. I would suggest another computer, one you don't care about or running a different distro of Linux. From this system, you can run these tools.

I posted Issue 2329 to Moritz Bunkus' GitLab issue-reporting site:

My friend, for years I've wanted to use mkvtoolnix on my host (I am a paid and registered user of MakeMKV on Linux), but Linux Mint/Ubuntu is just always several releases (58 against 62) behind for this C++ library. What are the options? Could you make a statically linked version available for building (I don't mind building stuff by hand if I have to)? Thanks for your consideration.

In response to my question (and to a request I did not make), he said,

I don't support Mint. I won't offer anything for it. You basically have three options:

  1. Compile an older MKVToolNix that doesn't require that new a version (you can check NEWS.md for notes when newer Boost versions were required),
  2. Compile and install your own current version of Boost,
  3. Upgrade to a newer version of Mint or, if not available, switch to a different distribution, e.g. a current Ubuntu.

Note: This stopped being a problem in Linux Mint 19.

Experience on Linux Mint 20.4, 2 February 2021

russ@tirion ~/Downloads $ wget -q -O - https://www.bunkus.org/gpg-pub-moritzbunkus.txt | sudo apt-key add -
OK
russ@tirion ~/Downloads $ sudo vim /etc/apt/sources.list.d/mkvtoolnix.download.list
russ@tirion ~/Downloads $ sudo apt-get update
russ@tirion ~/Downloads $ sudo apt-get install mkvtoolnix mkvtoolnix-gui
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mkvtoolnix : Depends: libdvdread4 (>= 4.1.3) but it is not installable
 mkvtoolnix-gui : Depends: libcmark0 but it is not installable
                  Depends: libdvdread4 (>= 4.1.3) but it is not installable
E: Unable to correct problems, you have held broken packages.

How to tell Plex one or more files is a single video

Plex has the capacity to play two halves (as used to be quite common for laying down long movies on DVD, for example, Das Boot) simply by continuing on to play the second or subsequent parts.

To get the two or more media files to play sequentially, you must name them when you lay them down in HandBrake, e.g.:

2074522525 Mar 25  2016 'The Lord of the Rings--The Fellowship of the Ring, part 1.mkv'
2446534409 Mar 25  2016 'The Lord of the Rings--The Fellowship of the Ring, part 2.mkv'


How to combine two MKV files into a single video

First, see How to tell Plex one or more files is a single video.

Why would you wish to do this? While Plex has the capacity to play two halves simply by continuing on to play the second or subsequent parts, if you've been counting on subtitles or other per-media settings, you must stop and re-engage them—an impossible feat since the Plex application interface merges them into the representation of a single one.

The result is that halfway (or partway) through viewing the title, you losing the subtitles unless you tell HandBrake to burn them in permanently (a practice I abhor).

So, let's say you have used MakeMKS to transcode Das Boot, which is on both sides of the (old) DVD and you want them to be a single file for the reasons just explained (or any other, such as mere convenience).

MKV Merge, part of MKVToolNix

(This is a refinement of Combine two MKV files into one video.)

  1. Launch MKV Merge.
  2. Click Add at top right.
  3. Browse to and add the first (Matrovska) file. (then)
  4. Click Append (again, at top right).
  5. Browse to and add your second (or subsequent) video file.
  6. (Lather, rinse, repeat for any subsequent files beyond the 2 if the case.)
  7. Choose the name to use in creating the single file and also the output filesystem location for the file.
  8. Click Start.

There is an assumption that that chosen audio language, subtitles and video resolution are the same. (Your mileage may vary. This did not work for me.)


How to combine two MKV files into a single video, second try

Here's how I combined title, Das Boot, which is 3 hours and 28 minutes in length, into a single Matroska file. This is the full, step-by-step procedure. In MKVToolNix' GUI version, this is call the Multiplexer.

  1. Using MakeMKV, I transcoded each side of the disk into two separate files.
  2. Using HandBrake, I again transcoded each file, injecting subtitles for English and French, into two files. I used my nephew's magic YIFY settings to reduce the filesize to about 10% without loss.
    • Das Boot, part 1.mkv
    • Das Boot, part 2.mkv
  3. I launched MKVToolNix GUI (/usr/bin/mkvtoolnix-gui).
  4. Click Add source files.
  5. Navigate to and select Das Boot, part 1.mkv.
  6. In Source files:, see this file; right-click on it and choose Append files (do not do Add files).
  7. Click on Das Boot, part 2.mkv; click Open.
  8. Click on Destination file: and enter the name Das Boot (full).mkv. You should see something like this:

  9. Click the Start multiplexing button. This doesn't take very long—only a few seconds.
  10. In your working directory, you should see:
    russ@tirion ~/Videos $ ll
    ...
    -rw-rw-r--  1 russ russ 1304366683 Jan  6 15:38 'Das Boot (full).mkv'
    -rw-rw-r--  1 russ russ  707686481 Jan  6 15:10 'Das Boot, part 1.mkv'
    -rw-rw-r--  1 russ russ  598969012 Jan  6 15:10 'Das Boot, part 2.mkv'
    
  11. Copy this new file to your Plex Media server:
    russ@tirion ~/Videos $ scp "Das Boot (full).mkv" tol-eressea:/plex-movies/Movies/Das\\\ Boot/
    Das Boot (full).mkv                                             100% 1244MB  89.5MB/s   00:13
    
  12. At this point, you can use Plex' browser application to integrate this title into its library. This worked for me and I had French and English subtitles all the way to the end of the movie through both parts.