AVC sequence header AAC sequence header
推送H.264和AAC的重要前提
RTMP的音視頻流的封裝形式和FLV格式相似, 流媒體服務(wù)器向客戶端發(fā)送包含H264和AAC的RTMP直播流,需要首先發(fā)送:
- AVC sequence header
- AAC sequence header
這兩個(gè)header非常重要,是客戶端解碼的必需部分.
因?yàn)橐陨蟽蓚€(gè)參數(shù)只在客戶端開始拉流開始的時(shí)候接收一次.
所以當(dāng)H264參數(shù)發(fā)生變化時(shí)(如分辨率或幀率等)發(fā)生變化或AAC音頻參數(shù)發(fā)生變化(采樣率等),這時(shí)候兩個(gè)header的內(nèi)容也會(huì)發(fā)生變化. 這時(shí)候如果不重新拉流,就會(huì)出現(xiàn)綠屏或花屏的現(xiàn)象(因?yàn)榻獯a參數(shù)已經(jīng)發(fā)生變化).
因此這時(shí)候應(yīng)該客戶端應(yīng)該進(jìn)行重新拉流(重新接受兩個(gè)header),畫面就會(huì)恢復(fù)正常.
那這兩個(gè)神奇的header究竟都藏了些什么具體信息呢?
AVC sequence header
?
AVCDecoderConfigurationRecord
Refer from H.264-AVC-ISO_IEC_14496-15.pdf
?
AVCDecoderConfigurationRecord的一些參數(shù)
解碼時(shí),解碼器通過(guò)Profile知道需要準(zhǔn)備那些參數(shù), 通過(guò)level知道圖像可能的最大的分辨率和幀率,通過(guò)SPS信息可計(jì)算出寬和高(如果信息充分還可計(jì)算出幀率信息).
AAC sequence header
AAC中用AudioSpecificConfig結(jié)構(gòu)體來(lái)表示AAC sequence header.
AudioSpecificConfig ()
{
audioObjectType = GetAudioObjectType();
samplingFrequencyIndex;
if ( samplingFrequencyIndex == 0xf )
{
samplingFrequency;
}
channelConfiguration;
...
}
Refer from ISO-14496-3(2009-09).pdf
AudioSpecificConfig
Audio Object Types
Audio Object Types部分列表
samplingFrequencyIndex
A four bit field indicating the sampling rate used. If samplingFrequencyIndex equals 15 then the actual sampling rate is signaled directly by the value of samplingFrequency . In all other cases samplingFrequency is set to the value of the corresponding entry in Table 1.18.
通過(guò)查詢下表可獲取實(shí)際的采樣率, 如samplingFrequencyIndex等于0x5, 查表可知當(dāng)前的音頻采樣率為32000.
Sampling Frequency Index
?
samplingFrequency
The sampling frequency used for this audio object. Either transmitted directly, or coded in the form of samplingFrequencyIndex.
音頻的采樣率. 可用samplingFrequency直接來(lái)指定, 或者用samplingFrequencyIndex來(lái)指定.
channelConfiguration
用于描述聲道信息, 常用的值有2, 立體聲雙聲道.
channelConfiguration
?
References:
http://download.csdn.net/download/winlinvip/6602533
http://download.csdn.net/download/stormjiang/6290515
http://www.cnblogs.com/haibindev/archive/2011/12/29/2305712.html
作者:FlyingPenguin
鏈接:https://www.jianshu.com/p/0bff0fc2bf28
來(lái)源:簡(jiǎn)書
簡(jiǎn)書著作權(quán)歸作者所有,任何形式的轉(zhuǎn)載都請(qǐng)聯(lián)系作者獲得授權(quán)并注明出處。
總結(jié)
以上是生活随笔為你收集整理的AVC sequence header AAC sequence header的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: MPEG4 (ISO/IEC 14496
- 下一篇: 【H264/AVC 句法和语义详解】(五