Perl script to parse ADTS audio header

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)

And here’s the script in GitHub

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s