[Matroska-devel] Hi, question about the MKV tags

Moritz Bunkus moritz at bunkus.org
Mon Feb 14 19:00:33 CET 2011


 Hey,

 On Mon, 14 Feb 2011 17:03:41 +0100, Steve Lhomme wrote:

> So are we back to using double Seek Heads ? I thought this was
> deprecated. It adds extra complexity for a fundamental part that is
> supposed to make the file handling easier.

 It's almost trivial to support linked seekheads -- simply make seekhead 
 parsing recursive.

 Also it's not the standard behaviour of mkvmerge. But mmg's chapter 
 editor/track header editor and mkvpropedit will fall back to creating 
 such structures if there's not enough room before the first cluster for 
 storing the whole seekhead. There are only three options in such cases:

 1. refuse to modify the file,
 2. remux the whole file into a temporary one & overwrite the original 
 one afterwards and
 3. create two linked seekheads, a small one before the first cluster 
 and a larger one at the back of the file.

 Like I said, this is the exception, not the rule.

> It is valid indeed but kinda defeat the point of the Seek Head if you
> find Level 1 elements before.

 The simplest algorithm that works both with seekable and with 
 non-seekable files is:

 while (!cluster_found) {
   read_next_level1_element
   if (is_cluster)
     break;
   else if (is_seekhead && stream_is_seekable)
     parse_seekhead_and_read_other_level1_elements;
   else if (is_track_headers)
     parse_track_headers;
   else if (is_segmentinfo)
   ...
 }

 if (!segmentinfo_found || !track_headers_found)
   error;

 Also it doesn't defeat any point. The seekhead can still (and most 
 likely will) point to stuff at the end of the file, e.g. at least the 
 cues.

> Luckily with such a design it matters less is
> the Seek Head is at the front or not (ie more mkvmerge friendly),

 mkvmerge doesn't care. If it finds a seekhead before the first cluster 
 then that seekhead and all the ones referenced from it are used. If it 
 doesn't then mkvmerge requires the track headers and segment info to be 
 located before the first cluster as well. If it also finds 
 tags/attachments/chapters before the first cluster then those are used 
 as well. Pretty much like the dummy algorithm above: "it will be used if 
 it is found by reading up to the first cluster and following all 
 seekheads founduntil then".

 Regards,
 mosu




More information about the Matroska-devel mailing list