++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
最近在做跟 h264 encode/decode 相關的研究,目標是希望可以從 Android 的 MediaRecorder 當中取出 h264 的資訊。目前問題是在於 SPS 以及 PPS 到底要怎樣得到。由於 MediaRecorder 是寫入 mp4 檔案中,所以不得已只好來去分析一下 mp4 的檔案格式,發現沒有想像中的困難. 主要是參照 ISO/IEC 14496-15 這部份. 在 mp4 的檔案之中, 找到 avcC 這個字串, 之後就是接上 AVCDecoderConfigurationRecord. AVCDecoderConfigurationRecord 的 format 如下:
[cpp] view plain
- 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;
- }
- }
對照一下這樣就可以找到 SPS 和 PPS
+++++++++++++++++++++++++++++++++++++++++++++
vlc没有收到pps和sps
2010-10-08 16:16
问题 packetizer_h264 packetizer warning: waiting for SPS/PPS
是因为解码器只是在第一次执行编码的时候,才编码出 SPS、PPS、和I_Frame;
h264 packetizer has set so, that it sends sps/pps only first keyframe, I'm trying to figure what breaks if that is changed so sps/pps is written in every keyframe. [出自| ]解决办法:
1、编码器编码出每个关键帧都加上SPS、PPS ,据说通常情况编码器编出的 SPS、PPS是一样的,所以这种方法耗费资源。
2、在服务器接收到客户端请求时,发送第一个package 加上 SPS、PPS。
具体如下:
-
1、在 VideoOpenFileSource 添加一个变量 isFirstFrame;
- 2、构造时初始化 isFirstFrame = true;
-
3、在int VideoOpenFileSource::readFromBufferChain() 修改如下:
- 1 if(isFirstFrame == true) (= = += = (); } { +=[| 参考] ======================================================================== sdp 关于pps和sps的疑问: packetization-mode 主要是定义包的模式,单一 NALU单元模式(0);非交错(non-interleaved)封包模式(1);交错(interleaved)封包模式(2) sprop-parameter-sets 等于H.264 的序列参数集和图像参数 NAL单元,base64转换;(即= sps+pps) profile-level-id 这个参数用于指示 H.264 流的 profile 类型和级别。这知道这个是啥东东 参考 黑暗长老 ffmpeg decode 关于pps sps问题:
如何用C语言取出H.264ES文件里的nal(sps,pps)信息。比如width, height, profile等等
请高手指点指点。。。 -