H.264/AVC编码的FLV文件的第二个Tag: AVCDec
AVCDecoderConfigurationRecord即AVC Sequence Header。
对于H.264/AVC编码格式的FLV文件,onMetaData是第一个Tag,之后的第二个Tag就是AVCDecoderConfigurationRecord, 也是第一个Video Tag, 在FLV文件中一般情况也是出现1次。
**AVCDecoderConfigurationRecord in ISO/IEC 14496-15:2004(E)**
AVCDecoderConfigurationRecord包含H.264解码相关比较重要的sps和pps信息。
- 在给AVC解码器送数据流之前一定要把sps和pps信息送出否则的话解码器不能正常解码。
- 而且在解码器stop之后再次start之前,如seek、快进快退状态切换等,须重新送一遍sps和pps的信息。
FLV文件中的AVCDecoderConfigurationRecord
找了一个视频编码格式为H.264/AVC的文件来分析:
**AVCDecoderConfigurationRecord举例**
00 00 00 09:
onMetaData结束的标志.
**00 00 01 66 **:
4个字节的PreviousTagSize1,即上个Tag的大小(包括Tag Header和Tag Data),也就是onMetaData的大小。
09 00 00 2b 00 00 00 00 00 00 00:
即11个字节的FLV Tag Header。
FLV Tag
首个字节的
0x09表明该Tag是Video Tag。
17 00 00 00 00:
VideoTagHeader, 编码格式为AVC时,该Header长度为5。
VideoTagHeader in Adobe Flash Video File Format Specification Version 10.1
**VideoTagHeader**
首个字节0x17含义如下:
- 1: key frame(for AVC, a seekable frame)
- 7: AVC
0x17之后的那个字节表明: AVPacketType:
- 0x00: AVC Sequence header
- 0x01: AVC NALU
- 0x02: AVC end of sequence(lower level NALU sequence ender is not required or supported)
接下来就是AVCDecoderConfigurationRecord了。
**AVCDecoderConfigurationRecord in ISO/IEC 14496-15:2004(E)**
**AVCDecoderConfigurationRecord**
01 42 c0 1e ff e1:
需要注意的是第2个字节: 0x42,即十进制的66 (Baseline Profile)。
第6个字节0xe1, 它的后5位表示SPS的数目,0xe1的后5位就是0 0001,即1,说明存在一个SPS。
00 17:
表明SPS的数据长度,0x00 0x17,即23个字节,表明其后的23个字节都是SPS。
SPS
SPS一般以0x67开头(也可以是0x27等,首个字节的后5位表明该NALU的类型)。
01 00 04 68 cb 8c b2:
PPS
01: 表明PPS的数目。
00 04: 表明PPS的数据长度。
68 cb 8c b2: PPS, 一般以0x68开头。
至此,AVCDecoderConfigurationRecord结束。
References:
Information technology — Coding of audio-visual objects — Part 15:
Advanced Video Coding (AVC) file format
http://www.360doc.com/content/12/1212/15/4550476_253606537.shtml