Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AAC ADTS raw data strange header

I got some ADTS AAC raw data from somewhere(actually it is extracted from a demuxed file) and in theory it should be corrected encoded. it looks like this:

Frame1:

21 19 94 ED A1 09 45 58 09 40 02 CA AA 85 D4 E5 C5 58 A9 73 00 0C 75 1C 5D A7 4E 52 40 90 38 71 9C 65 D5 C4 22 0B 28 7D EF F8 42 33 15 03 BA 6C DE B1 74 B4 A1 4E 0A 21 05 15 34 6B FD D9 E7 8F BF FF 79 5C D3 7D 90 79 F6 65 57 08 3A F7 C5 14 85 5E D7 C3 7D 2A 85 E1 7A 86 BA 3A AC 13 0D AE D1 1B 65 69 B6 71 92 E5 8A BC CB 5C 7A 6F D7 F2 2B 38 C9 0E 2A 40 2F 8E 90 9B 1F A2 3A 9C 39 A8 35 CE 69 14 CD 64 54 70 00 50 07 CE 37 83 6E F0 01 18 AA A8 49 B2 8B 8F A1 37 17 1C 06 00 00 00 06 00 72

Frames2:

21 19 95 14 C2 0A A9 61 19 8B CB 9B 56 AE A7 0A A0 34 DA EA D9 34 28 0C F8 DC 0C 30 97 12 A7 DD 3F F5 FE 7B 65 52 61 6D 7F DA BE D3 EB 30 CA A6 94 54 8E D4 0A 32 E1 EA FD AD 02 82 B5 1E 40 4C 04 3A BE 56 21 5D 7D 5D B3 31 2A 5D AF 4E FF A6 48 B9 42 E3 87 DE 5C 59 4B B9 BB C3 2C AD 50 6B 35 C8 24 6C 06 82 86 B2 26 17 E2 C6 DD 9A 43 53 91 D3 68 8D 67 8E 7D 0A 28 EB 7D F1 BB FC 56 5E 13 25 F9 77 E6 27 BF DA 4E 09 38 86 20 0A 00 F9 C6 F0 1D DE 00 21 05 4F 28 C0 A0 5F 0E 18 00 03 00 0E

.....

And for each following frames there is a quite strange similiar header as:

21 19 xx xx

For examples:

21 19 94 E1 ..

21 19 95 03 ..

....

So do you know what does this header mean?

like image 454
user991800 Avatar asked Dec 03 '12 11:12

user991800


2 Answers

This is how ADTS AAC looks like, for example for stereo:

adts_header()
channel_pair_element()
adts_header()
channel_pair_element()
adts_header()
channel_pair_element()
adts_header()
channel_pair_element()
etc...

This seems like it's not ADTS header at all. ADTS header is typicaly not used in some other container, like mp4, but is used for standalone AAC files only. ADTS header starts with 12 bit syncword 1111 1111 1111. So all ones, and this is not the case in your example.

In case muxer stripped out any header there was, you might have raw AAC which should start with single_channel_element() in case of mono or channel_pair_element() in case of stereo.

single_channel_element() starts with 3 bits 000

cannel_pair_element() starts with 3 bits 001

Your sample starts with 0010 0001 0001 1001 so it might be channel_pair_element().

You probably have stereo but without any header, like so:

channel_pair_element()
channel_pair_element()
channel_pair_element()
channel_pair_element()
etc.

You should ask the muxer to tell you the number of channels, sampling rate, etc, and you are ready to continue decoding. Muxer should grab this info from mp4 or whichever container your AAC was originaly in.

like image 171
Danijel Avatar answered Nov 10 '22 11:11

Danijel


It most likely a mpeg4 latm format. if you run mediainfo tool to check, it will output as below:

$mediainfo a.aac 
General
Complete name                            : a.aac
Format                                   : LATM
File size                                : 821 KiB
Overall bit rate mode                    : Variable

Audio
Format                                   : AAC
Format/Info                              : Advanced Audio Codec
Format profile                           : HE-AACv2 / HE-AAC / LC
Bit rate mode                            : Variable
Channel(s)                               : 2 channels / 1 channel / 1 channel
Channel positions                        : Front: L R / Front: C / Front: C
Sampling rate                            : 48.0 KHz / 48.0 KHz / 24.0 KHz
Compression mode                         : Lossy

Such format usually generated after ADTS header removed or from DTV channel. DTV data transfer use LATM format to save bandwidth, so no ADTS header there but use some codec config buffer to initialize decoder.

like image 34
lucky1928 Avatar answered Nov 10 '22 11:11

lucky1928