读书人

【多媒体打包格式详解】-MKV【3】

发布时间: 2012-11-26 11:48:49 作者: rapoo

【多媒体封装格式详解】---MKV【3】

有了上文我们经知道了MKV文件时长、音视频的类型、分辨率、采样率等基本信息,接下来就是音视频的数据了。

4.Clusters所有的音视频帧数据都在这部分内装着。1个Cluster内可能有很多个BlockGroup组成,BlockGroup内又由若干个Block组成。这些Block内就是音视频的帧数据。1个Cluster并不一定只是音频或者视频。它是由不同的音视频BlockGroup交叉组成。因为多媒体文件中的音视频数据本来就是交叉出现的。ClustersClusterTimecode BlockGroupBlockBlockGroupBlockReferenceBlockBlockGroupBlockClusterTimecode BlockGroupBlockBlockGroupBlockBlockGroupBlockBlockGroupBlockBlockDurationElement NameLEBML IDMaMuRngDefaultT123WDescription ClusterCluster1[1F][43][B6][75]-*--m****The lower level element containing the (monolithic) Block structure.Timecode2[E7]*---u****Absolute timecode of the cluster (based on TimecodeScale).SilentTracks2[58][54]----m*** The list of tracks that are not used in that part of the stream. It is useful when using overlay tracks on seeking. Then you should decide what track to use.SilentTrackNumber3[58][D7]-*--u*** One of the track number that are not used from now on in the stream. It could change later if not specified as silent in a further Cluster.Position2[A7]----u*** The Position of the Cluster in the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.PrevSize2[AB]----u****Size of the previous Cluster, in octets. Can be useful for backward playing.SimpleBlock2[A3]-*--b ***Similar to Block but without all the extra information, mostly used to reduced overhead when no extra feature is needed. (see SimpleBlock Structure)BlockGroup2[A0]-*--m****Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.Block3[A1]*---b****Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode. (see Block Structure)BlockVirtual3[A2]----b A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see Block Virtual)BlockAdditions3[75][A1]----m*** Contain additional blocks to complete the main one. An EBML parser that has no knowledge of the Block structure could still see and use/skip these data.BlockMore4[A6]**--m*** Contain the BlockAdditional and some parameters.BlockAddID5[EE]*-not 01u*** An ID to identify the BlockAdditional level.BlockAdditional5[A5]*---b*** Interpreted by the codec as it wishes (using the BlockAddID).BlockDuration3[9B]---TrackDurationu****The duration of the Block (based on TimecodeScale). This element is mandatory when DefaultDuration is set for the track (but can be omitted as other default values). When not written and with no DefaultDuration, the value is assumed to be the difference between the timecode of this Block and the timecode of the next Block in "display" order (not coding order). This element can be useful at the end of a Track (as there is not other Block available), or when there is a break in a track like for subtitle tracks. When set to 0 that means the frame is not a keyframe.ReferencePriority3[FA]*--0u*** This frame is referenced and has the specified cache priority. In cache only a frame of the same or higher priority can replace this frame. A value of 0 means the frame is not referenced.ReferenceBlock3[FB]-*--i****Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to.ReferenceVirtual3[FD]----i Relative position of the data that should be in position of the virtual block.CodecState3[A4]----b ** The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.Slices3[8E]----m****Contains slices description.TimeSlice4[E8]-*--m****Contains extra time information about the data contained in the Block. While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.LaceNumber5[CC]---0u****The reverse number of the frame in the lace (0 is the last frame, 1 is the next to last, etc). While there are a few files in the wild with this element, it is no longer in use and has been deprecated. Being able to interpret this element is not required for playback.FrameNumber5[CD]---0u The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).BlockAdditionID5[CB]---0u The ID of the BlockAdditional element (0 is the main Block).Delay5[CE]---0u The (scaled) delay to apply to the element.SliceDuration5[CF]---0u The (scaled) duration to apply to the element.ReferenceFrame3[C8]----m DivX trick track extenstionsReferenceOffset4[C9]*---u DivX trick track extenstionsReferenceTimeCode4[CA]*---u DivX trick track extenstionsEncryptedBlock2[AF]-*--b Similar to SimpleBlock but the data inside the Block are Transformed (encrypt and/or signed). (see EncryptedBlock Structure)
还有用之前的例子 【多媒体打包格式详解】-MKV【3】
Cluster ID = [1F][43][B6][75]size = 0x12468f (1197711)剩下的1197711的数据就是这个Cluster 的data第一个EBML元素 是Timecode ID = E7 size = 1 值为0 (红框内)第二个元素ID = A0 查表可知这个EBML元素就是BlockGroup size = 96042 紧接着就是ID = A1 第三级EBML元素 Block size = 96038 Block 结构如下图Block HeaderOffsetPlayerDescription0x00+mustTrack Number (Track Entry). It is coded in EBML like form (1 octet if the value is < 0x80, 2 if < 0x4000, etc) (most significant bits set to increase the range).0x01+mustTimecode (relative to Cluster timecode, signed int16)0x03+-FlagsBitPlayerDescription0-3-Reserved, set to 04-Invisible, the codec should decode this frame but not display it5-6mustLacing
读书人网 >移动开发

热点推荐