如何把WMV视频格式工厂mov无损转换mp4无损封装到MKV容器中

多媒体封装格式(31)
Matroska&开源多媒体容器标准。MKV属于其中的一部分。
Matroska常见的有.MKV视频格式、MKA音频格式、.MKS字幕格式、.MK3D files (stereoscopic/3D video).
1.EBML(Extensible Binary Meta Language)
MKV是建立在EBML这种语言的基础上,所以要了解MKV格式需要先了解EBML这种语言。
EBML是一种类似于XML格式的可扩展二进制元语言,使用可变长度的整数存储,以节省空间。
EBML基本元素结构:
typedef struct {
vint ID // EBML-ID
vint size // size of element
char[size] data // data
} EBML_ELEMENT;
ID标志属性类型
size为后面data部分的大小
data部分为ID所标识属性的实际数据
上面可以看到ID和size的类型都是vint,vint(Unsigned Integer Values of Variable Length)可变长度无符号整型,比传统32/64位整型更加节省空间。
长度计算方法为
长度 = 1 +整数前缀0比特的个数.
从MKV文件中简单接一段来举个例子。这是16进制表示方式
因为每个EBML元素都是由ID size data 三部分组成,我们就按照这些来分析。
将0x428 转成2进制 为&01000010 &&&按照上面规则 &前面有1个0 所以知道ID的长度为2,也就是0x4282为ID值。
将0x88 转成2进制为&10001000&1为开头 长度就是1,去掉前缀1变成了 ,也就是 size的值为 8.
接下来的8个字节就是data值:6D 61 74 72 6F 73 6B 61& 根据上面ID值查表得知 这个EMBL 名称为DocType&也就是说data的内容是string格式,所以转成askII码 data值就是“matroska” 和后面显示的一致。
所以这个EBML元素就解析出来了
ID=0x4282;
data=“matroska” ;
得到的信息就是&DocType&=&matroska。
2.整体结构
让我们看看MKV的整体框架结构。
EBMLVersion
Meta Seek Information
SeekPosition
SeekPosition
Segment Information
SegmentUID
TrackEntry
TrackNumber
TrackEntry
TrackNumber
Edition Entry
BlockGroup
BlockGroup
ReferenceBlock
BlockGroup
BlockGroup
BlockGroup
BlockGroup
BlockGroup
BlockDuration
Cueing Data
CuePosition
CuePosition
Attachment
Attachments
AttachedFile
AttachedFile
MultiTitle
MultiTitle
EBML元素都有自己的级别,每一个高一级的元素由若干次一级的元素组成。
从整个MKV文件整体来看可分为2大部分:
EBML Header和Segment。
EBML Header由EBMLVersion、DocType等子元素组成,包含了文件的版本、文档类型等相关信息。
Segment部分保存了媒体文件的视频和音频的实际数据,其data部分又可以分为SeekHead、Tracks、Cluster等若干子元素。
上文已经了解了EBML基本结构和MKV文件的整体结构,接下来我们自己分析每一部分。
1.EBML Header
MKV文件的开头部分是EBML header。可能会包括以下的内容
Element Name
Description
EBML Header
[1A][45][DF][A3]
Set the EBML characteristics of the data to follow. Each EBML document has to start with this.
EBMLVersion
The version of EBML parser used to create the file.
EBMLReadVersion
The minimum EBML version a parser has to support to read this file.
EBMLMaxIDLength
The maximum length of the IDs you'll find in this file (4 or less in Matroska).
EBMLMaxSizeLength
The maximum length of the sizes you'll find in this file (8 or less in Matroska). This does not override the element size indicated at the beginning of an element. Elements that have an
indicated size which is larger than what is allowed by EBMLMaxSizeLength shall be considered invalid.
A string that describes the type of document that follows this EBML header. 'matroska' in our case or 'webm' for webm files.
DocTypeVersion
The version of DocType interpreter used to create the file.
DocTypeReadVersion
The minimum DocType version an interpreter has to support to read this file.
上面是官方文档,找个例子简单看一下。下面是一个mkv文件的开头截图
按照上文EBML格式来解析
&长度3+1 &ID = 1A 45 DF A3
&长度1 &size=19
data 就是之后19个字节内容
对照上面的表可以得知整个EBML header为红线圈住的内容
按照EBML规则进一步解析内容可得知
DocType =&matroska
DocTypeVersion = 1
DocTypeReadVersion = 1
和官方工具对比发现完全一致
这里要说一下容器格式的可辨识性信息,一般的容器格式开头都有自己唯一的可辨识性信息,如flv文件开头三个字节'F' 'L' 'V' .这个可以让播放器来自动辨识容器格式。
MKV头部的1A 45 DF A3就是类似这种内容,如果发现开头是这4个字节,很有可能就是MKV文件。会继续进行解析。可以看看ffmpeg中matroska_probe&
MKV除了上面的EBML header,剩下的都属于Segment。里面包括了音视频信息、音视频数据等等。
还是用上面那个文件作为例子。用EBML方法继续解析。
ID = 18 53 80 67&
size = 01 EC D8 D4 ()
查表可知&ID = 18 53 80 67 对应的就是Segment&
Element Name
Description
[18][53][80][67]
This element contains all other top-level (level 1) elements. Typically a Matroska file is composed of 1 segment.
Segment中可能出现的是下面这些内容。
Meta Seek Information
Segment Information
Cueing Data
Attachment
1.Meta Seek Information
Meta Seek Information 其实是个快速索引的信息。他可能包含Track information, Chapters, Tags, Cues, Attachments, 这些部分的位置信息。这些位置是在Segment中的相对位置。Meta Seek这部分内容比不一定必须有,但是有了它能让你快速的定位到你关心的一些关键信息的位置,而不用按照文件顺序的解析。
Contains a single seek entry to an EBML element.
The binary ID corresponding to the element name.
SeekPosition
The&&of the element in
the segment in octets (0 = first level 1 element).
上文提到过了EBML元素都有自己的级别,每一个高一级的元素由若干次一级的元素组成。下图就是meta seek 结构
Meta Seek Information
SeekPosition
SeekPosition
还是以上面的MKV文件为例子。Segment中第一部分很可能就是meta seek。
红线圈里就是seek 内同,按照规范中的表解析EBML元素
11 4D 9B 74 表示SeekHead&
C0 解析后 size 64&
接下来就是SeekHead 下一级元素&
ID = 4D BB
data = 53 AB 84 16 54 AE 6B 53 AC 82 10 03&
data里面的信息就是seekID&和&SeekPosition
53 AB 表示seekID元素&
seekID =&15 49 A9 66&
53 AC 表示SeekPosition元素&
SeekPosition =&10 03 &(4099)
这个表示 ID 为&15
49 A9 66 &的EBML元素 所在Segment的位置为 4099处.查表可知道这个ID是
Segment Information 中的 info&
这个4099 是Segment中的相对位置,把之前24字节的EBML header &和 12字节Segment的ID和size加上 正好是4135,咱们找到文件7)的位置看看
正好是info 的位置。所以有了meta seek的信息我们可以快速找到一些关键EBML元素的位置。
把剩下meta
seek信息同样方法解析出来就会等到如下信息:
2.Segment Information
Segment Information&包含识别文件的信息,包括&Title&、&SegmentUID,有个比较关心的文件时常信息Duration也在这一部分。
Element Name
Description
SegmentUID
A randomly generated unique ID to identify the current segment between many others (128 bits).
SegmentFilename
A filename corresponding to this segment.
[3C][B9][23]
A unique ID to identify the previous chained segment (128 bits).
PrevFilename
[3C][83][AB]
An escaped filename corresponding to the previous segment.
[3E][B9][23]
A unique ID to identify the next chained segment (128 bits).
NextFilename
[3E][83][BB]
An escaped filename corresponding to the next segment.
SegmentFamily
A randomly generated unique ID that all segments related to each other must use (128 bits).
ChapterTranslate
A tuple of corresponding ID used by chapter codecs to represent this segment.
ChapterTranslateEditionUID
Specify an edition UID on which this correspondance applies. When not specified, it means for all editions found in the segment.
ChapterTranslateCodec
The&&using this ID (0: Matroska Script, 1: DVD-menu).
ChapterTranslateID
The binary value used to represent this segment in the chapter codec data. The format depends on the&used.
Duration of the segment (based on TimecodeScale).
General name of the segment.
Muxing application or library (&libmatroska-0.4.3&).
WritingApp
Writing application (&mkvmerge-0.3.3&).
Track包含了音视频的基本信息,如音视频解码器类型、视频分辨率、音频采样率等这。通过对Track部分的解析。我们就能得到音视频的基本信息。为选择相应解码器以及初始化这些解码器做好准备工作。每个&TrackEntry 代表着1条轨道信息。
TrackEntry
TrackNumber
TrackEntry
TrackNumber
Element Name
Description
[16][54][AE][6B]
A top-level block of information with many tracks described.
TrackEntry
Describes a track with all elements.
TrackNumber
The track number as used in the Block Header (using more than 127 tracks is not encouraged, though the design allows an unlimited number).
A unique ID to identify the Track. This should be kept the same when making a direct stream copy of the Track to another file.
A set of track types coded on 8 bits (1: video, 2: audio, 3: complex, 0x10: logo, 0x11: subtitle, 0x12: buttons, 0x20: control).
FlagEnabled
Set if the track is usable. (1 bit)
FlagDefault
Set if that track (audio, video or subs) SHOULD be active if no language found matches the user preference. (1 bit)
FlagForced
Set if that track MUST be active during playback. There can be many forced track for a kind (audio, video or subs), the player should select the one which language matches the user preference or the default + forced track. Overlay MAY happen between a forced
and non-forced track of the same kind. (1 bit)
FlagLacing
Set if the track may contain blocks using lacing. (1 bit)
The minimum number of frames a player should be able to cache during playback. If set to 0, the reference pseudo-cache system is not used.
The maximum cache size required to store referenced frames in and the current frame. 0 means no cache is needed.
DefaultDuration
[23][E3][83]
Number of nanoseconds (not scaled via TimecodeScale) per frame ('frame' in the Matroska sense -- one element put into a (Simple)Block).
TrackOffset
A value to add to the Block's Timecode. This can be used to adjust the playback offset of a track.
MaxBlockAdditionID
The maximum value of&. A value 0 means there is no&&for
this track.
A human-readable track name.
[22][B5][9C]
Specifies the language of the track in the.
An ID corresponding to the codec, see the&for more info.
CodecPrivate
Private data only known to the codec.
[25][86][88]
A human-readable string specifying the codec.
AttachmentLink
The UID of an attachment that is used by this codec.
CodecSettings
[3A][96][97]
A string describing the encoding setting used.
CodecDownloadURL
[26][B2][40]
A URL to download about the codec used.
CodecDecodeAll
The codec can decode potentially damaged data (1 bit).
TrackOverlay
Specify that this track is an overlay track for the Track specified (in the u-integer). That means when this track has a gap (see)
the overlay track should be used instead. The order of multiple TrackOverlay matters, the first one is the one that should be used. If not found it should be the second, etc.
TrackTranslate
The track identification for the given Chapter Codec.
TrackTranslateEditionUID
Specify an edition UID on which this translation applies. When not specified, it means for all editions found in the segment.
TrackTranslateCodec
The&&using this ID (0: Matroska Script, 1: DVD-menu).
TrackTranslateTrackID
The binary value used to represent this track in the chapter codec data. The format depends on the&&used.
Video settings.
FlagInterlaced
Set if the video is interlaced. (1 bit)
StereoMode
Stereo-3D video mode (0: mono, 1: side by side (left eye is first), 2: top-bottom (right eye is first), 3: top-bottom (left eye is first), 4: checkboard (right is first), 5: checkboard (left is first), 6: row interleaved (right is first), 7: row interleaved
(left is first), 8: column interleaved (right is first), 9: column interleaved (left is first), 10: anaglyph (cyan/red), 11: side by side (right eye is first), 12: anaglyph (green/magenta), 13 both eyes laced in one Block (left eye is first), 14 both eyes
laced in one Block (right eye is first)) . There are some more details on&.
OldStereoMode
DEPRECATED, DO NOT USE. Bogus StereoMode value used in old versions of libmatroska. (0: mono, 1: right eye, 2: left eye, 3: both eyes).
PixelWidth
Width of the encoded video frames in pixels.
PixelHeight
Height of the encoded video frames in pixels.
PixelCropBottom
The number of video pixels to remove at the bottom of the image (for HDTV content).
PixelCropTop
The number of video pixels to remove at the top of the image.
PixelCropLeft
The number of video pixels to remove on the left of the image.
PixelCropRight
The number of video pixels to remove on the right of the image.
DisplayWidth
PixelWidth
Width of the video frames to display. The default value is only valid when&&is 0.
DisplayHeight
PixelHeight
Height of the video frames to display. The default value is only valid when&&is 0.
DisplayUnit
How DisplayWidth & DisplayHeight should be interpreted (0: pixels, 1: centimeters, 2: inches, 3: Display Aspect Ratio).
AspectRatioType
Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect ratio, 2: fixed).
ColourSpace
[2E][B5][24]
Same value as in AVI (32 bits).
GammaValue
[2F][B5][23]
Gamma Value.
[23][83][E3]
Number of frames per second.&Informationalonly.
Audio settings.
SamplingFrequency
Sampling frequency in Hz.
OutputSamplingFrequency
Sampling Frequency
Real output sampling frequency in Hz (used for SBR techniques).
Numbers of channels in the track.
ChannelPositions
Table of horizontal angles for each successive channel, see&.
Bits per sample, mostly used for PCM.
TrackOperation
Operation that needs to be applied on tracks to create this virtual track. For more details&on the subject.
TrackCombinePlanes
Contains the list of all video plane tracks that need to be combined to create this 3D track
TrackPlane
Contains a video plane track that need to be combined to create this 3D track
TrackPlaneUID
The trackUID number of the track representing the plane.
TrackPlaneType
The kind of plane this track corresponds to (0: left eye, 1: right eye, 2: background).
TrackJoinBlocks
Contains the list of all tracks whose Blocks need to be combined to create this virtual track
TrackJoinUID
The trackUID number of a track whose blocks are used to create this virtual track.
TrickTrackUID
TrickTrackSegmentUID
TrickTrackFlag
TrickMasterTrackUID
TrickMasterTrackSegmentUID
ContentEncodings
Settings for several content encoding mechanisms like compression or encryption.
ContentEncoding
Settings for one content encoding like compression or encryption.
ContentEncodingOrder
Tells when this modification was used during encoding/muxing starting with 0 and counting upwards. The decoder/demuxer has to start with the highest order number it finds and work its way down. This value has to be unique over all ContentEncodingOrder elements
in the segment.
ContentEncodingScope
A bit field that describes which elements have been modified in this way. Values (big endian) can be OR'ed. Possible values:
1 - all frame contents,
2 - the track's private data,
4 - the next ContentEncoding (next ContentEncodingOrder. Either the data inside ContentCompression and/or ContentEncryption)
ContentEncodingType
A value describing what kind of transformation has been done. Possible values:
0 - compression,
1 - encryption
ContentCompression
Settings describing the compression used. Must be present if the value of ContentEncodingType is 0 and absent otherwise. Each block must be decompressable even if no previous block is available in order not to prevent seeking.
ContentCompAlgo
The compression algorithm used. Algorithms that have been specified so far are:
1 - bzlib,
3 - Header Stripping
ContentCompSettings
Settings that might be needed by the decompressor. For Header Stripping (ContentCompAlgo=3), the bytes that were removed from the beggining of each frames of the track.
ContentEncryption
Settings describing the encryption used. Must be present if the value of ContentEncodingType is 1 and absent otherwise.
ContentEncAlgo
The encryption algorithm used. The value '0' means that the contents have not been encrypted but only signed. Predefined values:
1 - DES, 2 - 3DES, 3 - Twofish, 4 - Blowfish, 5 - AES
ContentEncKeyID
For public key algorithms this is the ID of the public key the the data was encrypted with.
ContentSignature
A cryptographic signature of the contents.
ContentSigKeyID
This is the ID of the private key the data was signed with.
ContentSigAlgo
The algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
ContentSigHashAlgo
The hash algorithm used for the signature. A value of '0' means that the contents have not been signed but only encrypted. Predefined values:
1 - SHA1-160
上表是track部分的官方文档。咱们还是用上面同样的例子来简单解析一下track 信息。
Segment Information之后紧接着就是track信息了。
整个红色框里的就是track 信息。它包含了2路TrackEntry的信息,分别是蓝绿框中的。
先看看第一个track内容,也就是蓝色框内。只看重要信息
AE 代表着这个整个EBML单元是一个TrackEntry&size 0xB5&
TrackNumber = 1 &&&ID = D7 &size = 1 &data = 1;
TrackType = 1&ID = 83 size = 1 data = 1; 查表得知 1 表示的是video 也就是这个tarck信息是视频信息。
CodecID =&V_MPEG4/ISO/AVC&ID = 86 &size = 15 data = &V_MPEG4/ISO/AVC&
PixelWidth = 1280& ID = B0 size = 2 data = 0x500(1280)
PixelHeight = 528& &ID = BA size = 2 data = 0x210(528)
用官方的工具解析结果
用同样的方法解析第2路track的信息可以得到
通过对track部分的解析,我们就知道了这个MKV文件包含了2路音视频数据。1路为264的视频、1路为AC3的音频。音视频的相关参数也拿到了。
有了上文我们经知道了MKV文件时长、音视频的类型、分辨率、采样率等基本信息,接下来就是音视频的数据了。
4.Clusters
所有的音视频帧数据都在这部分内装着。
1个Cluster内可能有很多个BlockGroup组成,BlockGroup内又由若干个Block组成。这些Block内就是音视频的帧数据。
1个Cluster并不一定只是音频或者视频。它是由不同的音视频BlockGroup交叉组成。因为多媒体文件中的音视频数据本来就是交叉出现的。
BlockGroup
BlockGroup
ReferenceBlock
BlockGroup
BlockGroup
BlockGroup
BlockGroup
BlockGroup
BlockDuration
Element Name
Description
[1F][43][B6][75]
The lower level element containing the (monolithic) Block structure.
SilentTracks
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.
SilentTrackNumber
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.
The&&of the Cluster in
the segment (0 in live broadcast streams). It might help to resynchronise offset on damaged streams.
Size of the previous Cluster, in octets. Can be useful for backward playing.
SimpleBlock
Similar to&&but without all the extra information,
mostly used to reduced overhead when no extra feature is needed. (see&)
BlockGroup
Basic container of information containing a single Block or BlockVirtual, and information specific to that Block/VirtualBlock.
Block containing the actual data to be rendered and a timecode relative to the Cluster Timecode. (see&)
BlockVirtual
A Block with no data. It must be stored in the stream at the place the real Block should be in display order. (see&)
BlockAdditions
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.
Contain the BlockAdditional and some parameters.
BlockAddID
An ID to identify the BlockAdditional level.
BlockAdditional
Interpreted by the codec as it wishes (using the BlockAddID).
BlockDuration
TrackDuration
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.
ReferencePriority
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.
ReferenceBlock
Timecode of another frame used as a reference (ie: B or P frame). The timecode is relative to the block it's attached to.
ReferenceVirtual
Relative&&of the data
that should be in position of the virtual block.
CodecState
The new codec state to use. Data interpretation is private to the codec. This information should always be referenced by a seek entry.
Contains slices description.
LaceNumber
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.
FrameNumber
The number of the frame to generate from this lace with this delay (allow you to generate many frames from the same Block/Frame).
BlockAdditionID
The ID of the BlockAdditional element (0 is the main Block).
The (scaled) delay to apply to the element.
SliceDuration
The (scaled) duration to apply to the element.
ReferenceFrame
ReferenceOffset
EncryptedBlock
Similar to&&but the data inside
the Block are Transformed (encrypt and/or signed). (see&)
还有用之前的例子&
[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 Header
Description
Track 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).
Description
Reserved, set to 0
Invisible, the codec should decode this frame but not display it
00 : no lacing
01 : Xiph lacing
11 : EBML lacing
10 : fixed-size lacing
Lace (when lacing bit is set)
Number of frames in the lace-1 (uint8)
0x01 / 0xXX
Lace-coded size of each frame of the lace, except for the last one (multiple uint8). *This is not used with Fixed-size lacing as it is calculated automatically from (total size of lace)
/ (number of frames in lace).
(possibly) Laced Data
Consecutive laced frames
第1字节 表示Track Number
第2-3字节表示Timecode
第4字节表示&flags&
看上面的例子,
Block data 第1个字节 0x81 &按照EBML解释方式&Track Number = 1,结合上文得知 这个Block 数据是track 1的数据。track 1对应的是video数据,解码器类型是H.264.也就是这个block 的数据是264帧数据
Timecode 为 0000
flags = 0&
Lace是根据&flags 的值来确定的。上面这个flags 5-6位都是0 所有是no lacing。剩下的96038
- 4 都是视频的帧数据。
将这个96034长度block 的数据转成NALU格式,然后加上从track部分中的CodecPrivate数据中解析出来的sps 和 pps 信息 保存到本地,应该就是1帧的264数据
用elecard 打开 果然是1帧I帧数据
按照这个套路,看看下一个
BlockGroup ID = A0&size = 0x2808
第一个block &ID = A1 size = 0x)
第1字节 表示Track Number & =2 &表示是track 2的数据,track是ac3 的音频。
第2-3字节表示Timecode = 0x0005;
第4字节表示&flags = 0x04
这个时候就要解析&Lace &&flags 第5-6位为10 所有属于fixed-size lacing
Fixed-size lacing 是如下的结构
Fixed-size lacing
In this case only the number of frames in the lace is saved, the size of each frame is deduced from the total size of the Block. For example, for 3 frames of 800 octets each :
Block head (with lacing bits set to 10)
Lacing head: Number of frames in the lace -1, i.e. 2
Data in frame 1
Data in frame 2
Data in frame 3
07+1 就是包含的帧数,因为是ac3的音频 可以看到 07后面紧接着就是ac3的同步头0x0b77(绿框)
用工具看看相对应的解析结果
按照这种逻辑和方法,我们就可以把mkv文件中的音视频数据流demux出来了。
5.Cueing Data
Cueing Data 这部分内容其实是关键帧的index,如果没有关键帧的index的话,在做seek、快进快退的时候是十分困难的。你要逐个包去找。之前说过flv文件中官方没有做I帧index的规定。但是在民间已经做了补充。mkv官方有对index的规范。那就是Cueing Data&
下面是结构图。
Cueing Data
CuePosition
CuePosition
Cueing Data
[1C][53][BB][6B]
A top-level element to speed seeking access. All entries are local to the segment. Should be mandatory for non&.
Contains all information relative to a seek point in the segment.
CueTrackPositions
Contain positions for different tracks corresponding to the timecode.
The track for which a position is given.
CueClusterPosition
The&&of the Cluster containing
the required Block.
CueRelativePosition
The relative position of the referenced block inside the cluster with 0 being the first possible position for an element inside that cluster.
CueDuration
The duration of the block according to the segment time base. If missing the track's DefaultDuration does not apply and no duration information is available in terms of the cues.
CueBlockNumber
Number of the Block in the specified Cluster.
CueCodecState
The&&of the Codec State
corresponding to this Cue element. 0 means that the data is taken from the initial Track Entry.
CueReference
The Clusters containing the required referenced Blocks.
继续看上面的例子,我们找到了Cues&&所在的位置。
ID = [1C][53][BB][6B]&表示Cues&size = 0x7f
紧接着每个ID = 0xBB 就是一个CuePoint,图中的绿色框中的就是一个。 size = 0xC
CueTime&ID = 0xB3 &size = 1 data = 0;
CueTrackPositions&&ID=0xB7 size=7 data=0xfef
& & & &CueTrack&ID=F7 size = 1 data = 1 表示这个位置的track num 值为1 &针对这个流应该是video
& & & &CueClusterPosition&ID = F1 size = 2 data =&15ef & 位置是在0x15ef(5615) 相对于Segment&
找到这个位置发现是第一个Clusters 上面章节分析了,这个族的video内容正好是关键帧。
按照这种方式 发现这个文件中共有8个cuepoint 信息
把这个文件中的264视频demux出来,用工具查看发现关键帧正好也是8个。
已经把MKV主要部分的内容作了一次详细的叙述,现在对mkv文件做个小结。
1.MKV的基本组成单元都是EBML格式。每个元素都有级别。一级一级的包括组成了mkv不同的部分。
2.MKV是由EBML header 和Segment 2大部分组成。Segment中又分Meta
Seek InformationSegment InformationTrackChaptersClustersCueing
DataAttachmentTagging
3.EBML header&部分包含着MKV可辨识性的信息。
4.Meta Seek Information包含其实部分位置信息。
Information&包含识别文件的信息,包括&Title&、&SegmentUID,有个比较关心的文件时常信息Duration也在这一部分
6.Track包含了音视频的基本信息,如音视频解码器类型、视频分辨率、音频采样率等。
7.真实的音视频数据信息交叉装在Clusters中
Data&关键帧index,对seek至关重要。
From:&http://blog.csdn.net/tx3344/article/details/8203260
&&相关文章推荐
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:121221次
积分:2895
积分:2895
排名:第11223名
原创:144篇
转载:164篇
评论:25条
(9)(23)(18)(30)(20)(30)(13)(11)(7)(10)(15)(15)(3)(9)(5)(2)(3)(2)(9)(3)(5)(23)(42)

我要回帖

更多关于 格式工厂mov无损转换mp4 的文章

 

随机推荐