Clarifications regarding multisegment Matroska files

“The time has come,” the Walrus said,
“To talk of many things:
Of shoes — and ships — and sealing-wax —
Of cabbages — and kings —
And why the sea is boiling hot —
And whether pigs have wings.”

– Lewis Caroll, Alice in Wonderland

In that other post about MKV features, I mentioned that it’s possible for an MKV file to contain more than one segment, but didn’t expand further on it, because I didn’t find it very useful (and because I was lazy). Anyway since I mentioned a way of abusing it in a post somewhere else, I thought the time had come to post what I know about them.

What is a “segment” anyway

You might want to think of an MKV segment as a file. Seriously, that’s the easiest way, since pretty much all MKV files only ever contain one segment. If you want a more precise explanation, an MKV segment is the actual “container” that wraps whatever media you have in it, while the file itself is just a given sequence of bytes on your harddrive.

How to create a multisegment MKV file

Simple. Take two or more MKV files (each containing one or more segments) and concatenate them. On Windows, this easiest done with the “copy” commandline tool, like so:
copy /b file1.mkv+file2.mkv+file3.mkv output.mkv
Or on Unix-like systems, with cat(1):
cat file1.mkv file2.mkv file3.mkv > output.mkv


While it will indeed work (at least with Haali’s splitter) it does not actually create a multisegment file. I’d explain this in more detail but :effort:

Now what? How is this useful?

It isn’t, really, except if you really like confusing people and hiding data in unexpected places. Most MKV parsers (including mkvmerge) will, when confronted with a multisegment file, just read the first segment. One notable exception is Haali’s splitter, which seems to generate a “playlist” of sorts, with all the segments in the order they were stored in the file.

Do note that since ordered chapters link to other segments by SUID and not by filename, it is perfectly valid to store multiple segments in one file and create a single timeline with ordered chapters.

One funny but probably not very useful or user-friendly application is to store different videos with different codecs/resolutions/other settings in a single file and use ordered editions to let the user choose which one to play back. Dual format releasing in a single file, MKV amazes again!
Another dumb usage would be to stuff some kind of seizure-inducing annoying video in the first segment, storing the actual video in the second segment and using ordered editions to make sure a viewer with proper software never sees the first segment at all. Jokes at the expense of VLC users never gets old.

If you come up with interesting ways to abuse this, please let me know as it is relevant to my interests.

Comments (2)

  1. lovelove wrote:


    –> ok, if copy /b is (obviously) not a valid method of creating multisegment mkv files, then WHAT IS THE CORRECT method of creating multisegment mkv files?

    Friday, September 2, 2011 at 07:02 #
  2. Ben wrote:

    Hi, I was browsing through your blog and I noticed you haven’t posted any new articles since June 2012. I hope you are ok and continue to be active on your blog.

    Your articles on Matroska are the most helpful and best-informed on the MKV subject I have presently found on the Internet. However, I need more exposition on creating multisegment MKV files. I’ve been using your method discussed here succesfully, but I’m really dying to know what is the correct way to create multisegment MKV files, especially since there are no programs I know of that can edit and extract secondary segments from a concatenated MKV file after it’s been published.

    Please don’t let this thread die.

    Sunday, October 28, 2012 at 08:19 #