直播工作

AVC sequence header & AAC sequen

2016-08-28  本文已影响0人  FlyingPenguin

推送H.264和AAC的重要前提

RTMP的音视频流的封装形式和FLV格式相似, 流媒体服务器向客户端发送包含H264和AAC的RTMP直播流,需要首先发送:

因为以上两个参数只在客户端开始拉流开始的时候接收一次.
所以当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

上一篇 下一篇

猜你喜欢

热点阅读