Last time I posted a script to parse MPEG-1 audio headers. This time, a script to parse MPEG-2 AAC audio headers:
Here’s the output for a typical file (download the file from GitHub)
>perl adtsaudioheader.pl ding.adts -- adts_fixed_header -- syncword: 11111111 1111 (should be all ones) ID: 1 (MPEG identifier, always 1) layer: 00 (layer, always 00) protection_absent: 1 (CRC error detection data IS NOT present) profile: 01 (Low Complexity profile (LC)) sampling_frequency_index: 0100 (44100 Hz) private_bit: 0 channel_configuration: 010 (2.0: L R) original_copy: 0 (not copyright) home: 0 (this is a copy) -- adts_variable_header -- copyright_identification_bit: 0 (copyright identification is transferred one bit per frame) copyright_identification_start: 0 (continuation of previous copyright identification, or no copyright) aac_frame_length: 00001111 11011 (507 bytes) adts_buffer_fullness: 11111111 111 (all ones means variable bit rate) number_of_raw_data_blocks_in_frame: 00 (1 blocks)
Note this script assumes that the very first bytes of the file are the MPEG audio header, and makes no effort to dig into the file to find the audio header.
EDIT 2015-10-31: moved script to https://github.com/mvaneerde/blog/blob/master/scripts/adtsaudioheader.pl