View Full Version : AVC in MKV Container
videophool
26th May 2012, 17:50
I am looking for technical information about H264 in MKV container. Is there a specification or document that describes how it is stored?
LoRd_MuldeR
26th May 2012, 17:54
Matroska Basic Specs:
http://www.matroska.org/files/matroska.pdf
Matroska Codec Specs:
http://haali.su/mkv/codecs.pdf
videophool
28th May 2012, 18:33
Matroska Basic Specs:
http://www.matroska.org/files/matroska.pdf
Matroska Codec Specs:
http://haali.su/mkv/codecs.pdf
The haali spec is useful for the codec private data. Beyond that, I do not see any specific discussion of how the AVC data is carried. For example, are the SPS/PPS carried in the sample data? Also, using a hex editor to inspect the AVC data in the MKV, the AVC structure is not clear (I can'd identify the NAL units).
Guest
28th May 2012, 18:49
The NAL units are delimited not by 00 00 01 start codes but by a length field. I'll send you a code sample in an email. The SPS/PPS's are included in the data stream.
LoRd_MuldeR
28th May 2012, 18:51
About SPS/PPS the Haali document says:
SPSs and PPSs are concatenated and stored at dwSequenceHeader, without SPS and PPS counts
Also this post might be helpful about NALU's:
http://forum.doom9.org/showpost.php?p=1320024&postcount=11
EDIT: neuron2 was faster.
Guest
28th May 2012, 18:54
Thanks, Lord_Mulder, I forgot about that post.
Watch out for header compression too. For AVC a single 00 byte is stored as the "header" when header compression is enabled for the file. That shortens all the start codes, as it is to be prepended when extracting the data.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.