{"id":14,"date":"2008-05-12T19:54:16","date_gmt":"2008-05-12T18:54:16","guid":{"rendered":"http:\/\/www.uppcon.se\/thefluff\/hurfdurf\/?p=14"},"modified":"2009-07-07T19:10:39","modified_gmt":"2009-07-07T18:10:39","slug":"clarifications-regarding-multisegment-matroska-files","status":"publish","type":"post","link":"https:\/\/mod16.org\/hurfdurf\/?p=14","title":{"rendered":"Clarifications regarding multisegment Matroska files"},"content":{"rendered":"<blockquote><p>&#8220;The time has come,&#8221; the Walrus said,<br \/>\n&#8220;To talk of many things:<br \/>\nOf shoes &#8212; and ships &#8212; and sealing-wax &#8212;<br \/>\nOf cabbages &#8212; and kings &#8212;<br \/>\nAnd why the sea is boiling hot &#8212;<br \/>\nAnd whether pigs have wings.&#8221;<\/p><\/blockquote>\n<p><i>&#8212; Lewis Caroll, Alice in Wonderland<\/i><\/p>\n<p>In <a href=\"http:\/\/www.uppcon.se\/thefluff\/hurfdurf\/?p=8\">that other post about MKV features<\/a>, I mentioned that it&#8217;s possible for an MKV file to contain more than one segment, but didn&#8217;t expand further on it, because I didn&#8217;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.<br \/>\n<!--more--><\/p>\n<h3>What is a &#8220;segment&#8221; anyway<\/h3>\n<p>You might want to think of an MKV segment as a file. Seriously, that&#8217;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 &#8220;container&#8221; that wraps whatever media you have in it, while the file itself is just a given sequence of bytes on your harddrive.<\/p>\n<h3>How to create a multisegment MKV file<\/h3>\n<p>Simple. Take two or more MKV files (each containing one or more segments) and concatenate them. On Windows, this easiest done with the &#8220;copy&#8221; commandline tool, like so:<br \/>\n<code>copy \/b file1.mkv+file2.mkv+file3.mkv output.mkv<\/code><br \/>\nOr on Unix-like systems, with cat(1):<br \/>\n<code>cat file1.mkv file2.mkv file3.mkv > output.mkv<\/code><\/p>\n<p style=\"text-decoration: blink; color: red;\">EDIT: NOTE THAT THE ABOVE IS WRONG AND HAS ALWAYS BEEN.<\/p>\n<p>While it will indeed work (at least with Haali&#8217;s splitter) it does not actually create a multisegment file. I&#8217;d explain this in more detail but :effort:<\/p>\n<h3>Now what? How is this useful?<\/h3>\n<p>It isn&#8217;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&#8217;s splitter, which seems to generate a &#8220;playlist&#8221; of sorts, with all the segments in the order they were stored in the file.<\/p>\n<p>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.<\/p>\n<p>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!<br \/>\nAnother 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 <i>never<\/i> gets old.<\/p>\n<p>If you come up with interesting ways to abuse this, please let me know as it is relevant to my interests.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;The time has come,&#8221; the Walrus said, &#8220;To talk of many things: Of shoes &#8212; and ships &#8212; and sealing-wax &#8212; Of cabbages &#8212; and kings &#8212; And why the sea is boiling hot &#8212; And whether pigs have wings.&#8221; &#8212; Lewis Caroll, Alice in Wonderland In that other post about MKV features, I mentioned [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,13],"tags":[],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-encoding","category-the-internet"],"_links":{"self":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=14"}],"version-history":[{"count":2,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions"}],"predecessor-version":[{"id":83,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=\/wp\/v2\/posts\/14\/revisions\/83"}],"wp:attachment":[{"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mod16.org\/hurfdurf\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}