mp4的box信息——avcC,mdat

来源:互联网 发布:雅思资料 知乎 编辑:程序博客网 时间:2024/05/16 10:35

前面忽略了avcC的box信息和mdat的格式信息,后面遇到了问题,现在在这里补充上这两个box的信息。

这2个box的信息在iso_iec-14496-15中。

//————avcC——————-//
5.3.4.1
Sample description name and format
5.3.4.1.1 Definition
Box Types:‘avc1’, ‘avcC’, ‘m4ds’,’btrt’
Container:Sample Table Box (‘stbl’)
Mandatory:The avc1 box is mandatory
Quantity:One or more sample entries may be present

5.3.4.1.2 Syntax

// Visual Sequencesclass AVCConfigurationBox extends Box(‘avcC’) {    AVCDecoderConfigurationRecord() AVCConfig;}class MPEG4BitRateBox extends Box(‘btrt’){    unsigned int(32) bufferSizeDB;    unsigned int(32) maxBitrate;    unsigned int(32) avgBitrate;}class MPEG4ExtensionDescriptorsBox extends Box(‘m4ds’) {    Descriptor Descr[0 .. 255];}class AVCSampleEntry() extends VisualSampleEntry (‘avc1’){    AVCConfigurationBox config;    MPEG4BitRateBox ();    // optional    MPEG4ExtensionDescriptorsBox (); // optional}

关于这个:AVCDecoderConfigurationRecord的说明:

aligned(8) class AVCDecoderConfigurationRecord {    unsigned int(8) configurationVersion = 1;    unsigned int(8) AVCProfileIndication;    unsigned int(8) profile_compatibility;    unsigned int(8) AVCLevelIndication;    bit(6) reserved = ‘111111’b;    unsigned int(2) lengthSizeMinusOne;    bit(3) reserved = ‘111’b;    unsigned int(5) numOfSequenceParameterSets;    for (i=0; i< numOfSequenceParameterSets; i++) {        unsigned int(16) sequenceParameterSetLength ;        bit(8*sequenceParameterSetLength) sequenceParameterSetNALUnit;    }    unsigned int(8) numOfPictureParameterSets;    for (i=0; i< numOfPictureParameterSets; i++) {        unsigned int(16) pictureParameterSetLength;        bit(8*pictureParameterSetLength) pictureParameterSetNALUnit;    }}

分析一段avcC的数据:

字段16进制 2进制 含义 00 00 00 2E size大小 61 76 63 43 ‘a’ ‘v’ ‘c’ ‘C’ 0x01 configurationVersion 0x4D AVCProfileIndication。10进制的77,对照profile的情况,知道是main profile 00 profile_compatibility .一般0 1F AVCLevelIndication.10进制的31 FF 1111 1111 前面6位为reserved,后面2位(0b11)为:lengthSizeMinusOne,表示3,那么用来表示size的字节就有3+1=4个 E1 1110 0001 前面3位是reserved,后面5bit是numOfSequenceParameterSets,表示有1个。 00 17 sequenceParameterSetLength 67 4D 00 1F 95 A8 14 01 6E 9B 80 80 80 A0 00 00 7D 00 00 0E A6 10 80 这0x17=23个字节就是sps的内容 01 numOfPictureParameterSets,有1个pps 00 04 pictureParameterSetLength 68 EE 3C 80 PPS的内容

回到mdat那里看:
00 20 FA 68 6D 64 61 74 00 00 00 17 67 4D 00 1F
95 A8 14 01 6E 9B 80 80 80 A0 00 00 7D 00 00 0E
A6 10 80 00 00 00 04 68 EE 3C 80 00 00 00 05 06

字段 含义 00 20 FA 68 6D 64 61 74 00 00 00 17 4个字节的长度信息,由上面的lengthSizeMinusOne+1决定 67 4D 00 1F 95 A8 14 01 6E 9B 80 80 80 A0 00 00 7D 00 00 0E A6 10 80 sps内容
0 0