[Matroska-devel] Tagging MKV files

Dan Hinsley danhi at cox.net
Sat Sep 1 18:31:36 CEST 2012


Thanks again, and ignore my last email.  I forgot that the program I wrote
to dump the data automatically outputted the actual offset.

So now my question is, since I'm moving the original SeekHead to the end of
the file, but still inside the same segment, the offset's should need to be
modified, correct?  Also, is the SeekHead always in a Segment element, or
could it be in something else?

Thanks again,

Dan

-----Original Message-----
From: matroska-devel-bounces at lists.matroska.org
[mailto:matroska-devel-bounces at lists.matroska.org] On Behalf Of Moritz
Bunkus
Sent: Saturday, September 01, 2012 9:19 AM
To: Discussion about the current and future development of Matroska
Subject: Re: [Matroska-devel] Tagging MKV files

Hey,

On Sat, Sep 1, 2012 at 6:06 PM, Dan Hinsley <danhi at cox.net> wrote:

> Thanks for the quick feedback.  I suspect it's #3 that's causing my
problem.
> Just so I understand, is the SeekHead always contained in a Segment,

Yes. A segment is a so called "level 0 element" and a seek head a
"level 1 element" (like e.g. the track headers, the clusters or the
segment info elements which are all level 1 elements as well).

> and then all offsets are from the start of that segment?

More precisely: the "seek position" elements are relative to the start
of the _data_ inside the segment, not relative to the position of the
segment element itself. Example output from mkvinfo (limited to the
relevant pieces of information):

+ Segment, size 115780 at 40
|+ Seek head at 52
...
| + Seek entry at 72
|  + Seek ID: 0x16 0x54 0xae 0x6b (KaxTracks) at 75
|  + Seek position: 4257 at 82
...
|+ Segment tracks at 4309
...

The segment element itself is located at position 40. However, this is
not relevant to our discussion. The very first element inside the
segment is the "seek head" at 52. Therefore, judging from mkvinfo's
output, the data start is at 52. This IS relevant.(*)

Now that "seek entry"'s "seek position" child has a value of 4257.
Adding the 52 from step 1 yields 4309 -- which is exactly the position
the element referred to is located at.

(*) Note that the correct way to calculate the segment data start
position is NOT by taking the first child element's start position. I
only do that in this example because that's the only way to do it with
mkvinfo's output only. In a program, however, you can easily calculate
it as "segment element position" + "size in bytes of the segment
element's ID" (which is 4) + "size in bytes of the segment length
field" (which is usually between 1 and 8 bytes). mkvmerge always
creates 8 bytes long "length" fields for the "segment" element,
therefore this calculation would yield 40 + 4 + 8 = 52 -- which is the
very same as the "seek head" element's position. Check OK.

Kind regards,
mosu
_______________________________________________
Matroska-devel mailing list
Matroska-devel at lists.matroska.org
http://lists.matroska.org/cgi-bin/mailman/listinfo/matroska-devel
Read Matroska-Devel on GMane:
http://dir.gmane.org/gmane.comp.multimedia.matroska.devel



More information about the Matroska-devel mailing list