AAC文件格式解析(今天有了一个新任务,要把RTSP的音频流存成文件,格式是AAC的。网上找了很久,也没有找到关于AAC文件的格式。 后来请教了一个专门作编解码的同事,在ISO MPEG的文档里可能会有相关的信息。 花了很长时间去找ISO的文档,ISO是收费的,网络是免费了,虽然难了点,但还是找到了部分的文档。其中辛苦不足为外人道也。 在找了个quicktime可以播放的aac文件,边看文档,边分析一下,总算是基本搞定了。但是有的文档没找到,还有些字段不知是什么意思。不管了,反正能放了:) AAC格式是frame head + frame length, 没有文件头。感到比较奇怪的,我觉得应该是有文件头的,文档上也有adts_fixed_header,但是好像没有头quicktime也能放,那就先不管了吧。 参见ISO/IEC 11496-3 1.1 Interchange format streams adts_frame() { byte_alignment() adts_fixed_header() adts_variable_header() adts_error_check() óISO/IEC ISO/IEC CD 14496-3 Subpart 4: 1998 MPEG-4 CD 14496-3 Subpart 4 / 20:09 / 22.06.98 11 for( i=0; i<number_of_raw_data_blocks_in_frame+1; i++) { raw_data_block() } } adts_fixed_header() { syncword ID layer protection_absent profile sampling_frequency_index private_bit channel_configuration original/copy home emphasis } adts_variable_header() { copyright_identification_bit 1 bslbf copyright_identification_start 1 bslbf frame_length 13 bslbf adts_buffer_fullness 11 bslbf number_of_raw_data_blocks_in_frame 2 uimsfb } 其中frame_buf是一帧的数据,framec_len是帧长度。 简单的说明和困惑: 长度为7个字节 syncword ID layer protection_absent profile sampling_frequency_index private_bit channel_configuration 在SDP中有 a=rtpmap:97 mpeg4-generic/44800 original/copy home emphasis copyright_identification_bit copyright_identification_start frame_length 最后添FC 文档不全,对编解码也知之甚少,只能靠分析别人的文件和试验了,至少能出声音了。 |
|