AVC sequence header AAC sequence header
推送H.264和AAC的重要前提
RTMP的音視頻流的封裝形式和FLV格式相似, 流媒體服務器向客戶端發送包含H264和AAC的RTMP直播流,需要首先發送:
- AVC sequence header
- AAC sequence header
這兩個header非常重要,是客戶端解碼的必需部分.
因為以上兩個參數只在客戶端開始拉流開始的時候接收一次.
所以當H264參數發生變化時(如分辨率或幀率等)發生變化或AAC音頻參數發生變化(采樣率等),這時候兩個header的內容也會發生變化. 這時候如果不重新拉流,就會出現綠屏或花屏的現象(因為解碼參數已經發生變化).
因此這時候應該客戶端應該進行重新拉流(重新接受兩個header),畫面就會恢復正常.
那這兩個神奇的header究竟都藏了些什么具體信息呢?
AVC sequence header
?
AVCDecoderConfigurationRecord
Refer from H.264-AVC-ISO_IEC_14496-15.pdf
?
AVCDecoderConfigurationRecord的一些參數
解碼時,解碼器通過Profile知道需要準備那些參數, 通過level知道圖像可能的最大的分辨率和幀率,通過SPS信息可計算出寬和高(如果信息充分還可計算出幀率信息).
AAC sequence header
AAC中用AudioSpecificConfig結構體來表示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.
通過查詢下表可獲取實際的采樣率, 如samplingFrequencyIndex等于0x5, 查表可知當前的音頻采樣率為32000.
Sampling Frequency Index
?
samplingFrequency
The sampling frequency used for this audio object. Either transmitted directly, or coded in the form of samplingFrequencyIndex.
音頻的采樣率. 可用samplingFrequency直接來指定, 或者用samplingFrequencyIndex來指定.
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
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯系作者獲得授權并注明出處。
總結
以上是生活随笔為你收集整理的AVC sequence header AAC sequence header的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MPEG4 (ISO/IEC 14496
- 下一篇: 【H264/AVC 句法和语义详解】(五