Welcome Guest ( Log In | Register )

Extract AAC audio data from FLV: Missing headers
post Dec 11 2011, 10:11
Post #1

Group: Members
Posts: 1
Joined: 11-December 11
Member No.: 95735


I try to extract the AAC data from a FLV video. According to the FLV specifications (see Annex E), I can read all audio tags in the FLV. Afterwards I can just put all the data which is contained in audio tags together. This works so far.
Unfortunately, my extracted .aac files are not playable by any player.

For testing purposes, I extracted the AAC data from the FLV by using ffmpeg:
ffmpeg -i video.flv -acodec copy audio.aac

This file is playable. I made a binary comparison between the two files. They are just differentiate in some bytes. The ffmpeg output file has some extra bytes included. They follow this pattern:
FF F1 50 80 XX XX FC 21 XX
These additional bytes are repeated about every 700 bytes and the XX can vary per occurence (not per file). At the beginning of the file, these bytes are missing several times.

Two images of the diff (start and middle of the file) are available here.

Does anyone know where these additional bytes come from?
And where they are specified in order to add them programmatically?

Go to the top of the page
+Quote Post
Start new topic
post Dec 31 2011, 19:51
Post #2

Winamp Developer

Group: Developer
Posts: 669
Joined: 17-July 05
From: Ashburn, VA
Member No.: 23375

The ADTS header is trivial to generate once you have the decoder configuration (stored in the first FLV packet) and the size for the current frame. Remember that the first byte of the FLV AAC data isn't part of the AAC frame, it's a 1 byte value indicated whether it's a decoder configuration frame or an audio frame.

There is information about the layout of the ADTS header here - http://wiki.multimedia.cx/index.php?title=ADTS
The FLV decoder configuration packet follows the MPEG-4 File Format convention for storing decoder configuration. It's usually 2 bytes (sometimes more in the case of HE-AAC), I can't remember the exact layout (and not at a computer where I'd have that information anywhere) but google should be able to find it nicely for you.
Go to the top of the page
+Quote Post

Posts in this topic

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:


RSS Lo-Fi Version Time is now: 20th April 2014 - 07:39