ADTS
If the data is to be streamed within an MPEG-2 transport stream, a self-synchronizing format called an Audio Data Transport Stream (ADTS) is used, consisting of a series of frames, each frame having a header followed by the AAC audio data.
- ADTS由一连串的ADTS Frame组成.
- 每个Frame由ADTS Header和AAC audio data组成.
用AAC Audio ES Viewer
工具打开一个.aac
文件进行分析:
ADTS的每一帧都有头信息,上图中绿色的7个字节为当前adts_frame
的ADTS Header
, 前三个字节0xFFF
为同步字符.
adts_sequence
adts_frame
一个AAC原始数据块长度是可变的,对原始帧加上ADTS头进行ADTS的封装,就形成了ADTS帧.
adts_fixed_header
syncword **
总是0xFFF
, 代表一个ADTS帧的开始, 用于同步.
解码器可通过0xFFF
确定每个ADTS的开始位置.
因为它的存在,解码可以在这个流中任何位置开始, 即可以在任意帧解码**。ID
MPEG Version: 0 for MPEG-4, 1 for MPEG-2layer
always: '00'protection_absent
Warning, set to 1 if there is no CRC and 0 if there is CRC
-
profile
表示使用哪个级别的AAC,如01 Low Complexity(LC) -- AAC LC
profile的值等于 Audio Object Type的值减1.
profile = MPEG-4 Audio Object Type - 1
-
sampling_frequency_index
采样率的下标.
通过上表可查询出下标对应的采样率.
比如sampling_frequency_index=5
对应的采样率为32000
.
-
channel_configuration
声道数. 比如2
表示立体声双声道.
adts_variable_header
-
aac_frame_length
一个ADTS帧的长度包括ADTS头和AAC原始流.
frame length, this value must include 7 or 9 bytes of header length:
aac_frame_length = (protection_absent == 1 ? 7 : 9) + size(AACFrame)
protection_absent=0时, header length=9bytes
protection_absent=1时, header length=7bytes
adts_buffer_fullness
0x7FF 说明是码率可变的码流.number_of_raw_data_blocks_in_frame
表示ADTS帧中有number_of_raw_data_blocks_in_frame + 1个AAC原始帧.
所以说number_of_raw_data_blocks_in_frame == 0 表示说ADTS帧中有一个AAC数据块。
(一个AAC原始帧包含一段时间内1024个采样及相关数据)
References:
13818-7(AAC).pdf
http://www.cnblogs.com/caosiyang/archive/2012/07/16/2594029.html
http://blog.csdn.net/bsplover/article/details/7426476
http://www.jianshu.com/p/0bff0fc2bf28
http://blog.csdn.net/whygosofar/article/details/4853743
https://wiki.multimedia.cx/index.php?title=ADTS