rtmp 音频发aac时候的关键帧和普通帧如何计算

rtmp 音频发aac的时候,帧有2中类型: 关键帧和普通帧。

关键帧的算法:

static const int mpeg4audio_sample_rates[16] = {
   96000, 88200, 64000, 48000, 44100, 32000,
24000, 22050, 16000, 12000, 11025, 8000, 7350
};
//get keyframe info.
for(index = 0; index < 16; index++) {
if(audio_sample_rate_rtmp == mpeg4audio_sample_rates[index]) {
break;
}
if( index == 16 ) {
printf_log("error sample rate!\n");
ret == -1;
goto clean;
}
}
m_keyframe[0] = 0x02 << 3 | index >> 1;
m_keyframe[1] = (index & 0x01) << 7 | audio_channels << 3;
m_keyframe_len = 2;
SendKeyFrame();

这样可以通过自己来计算得到,好处就是不用理你是什么编码器,太舒服了 嚎嚎嚎~~~~

 要是用faac编码器,可以用一下方法得到:

faacEncSetConfiguration(m_hEncoder, pConfiguration);
int ret = faacEncGetDecoderSpecificInfo(m_hEncoder, &m_pSpc, &m_nSpc);


普通帧:

就是从编码器得到的数据啦,,,,,嗬嗬嗬~~~~

关键帧的时间戳不用理,写0即可。

普通阵的时间戳一定要写对,并且是以毫秒作单位,不要搞错了啊。


你可能感兴趣的:(rtmp 音频发aac时候的关键帧和普通帧如何计算)