问题是这样的:当解码 H264 流时ffmpeg
,我可以获得SPS和PPS的原始数据,但我不知道如何将它们填充到extradata
现场AVCodecContext
。没有extradata
,我无法正确解码帧。每次我打电话avcodec_decodec_video2
,返回值为正,但got_picture
旗帜永远是zero
.
我正在处理的流看起来像这样:
[0x67]...[0x68]...[0x61]...[0x61]... ....... [0x61]...[0x67]...[0x68]... ......
您提到的数据是保存 SPS 和 PPS 的 NAL 单元的字节流。extradata
反过来,需要一个指向 AVC 解码器配置记录的指针,这是经过额外格式化的数据。
有关详细信息,请参阅 MPEG-4 第 15 部分“高级视频编码 (AVC) 文件格式”第 5.2.4.1 节。
5.2.4.1.1 Syntax
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;
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)