Hi,
I try to extract the AAC data from a FLV video. According to the FLV specifications (see Annex E (http://download.macromedia.com/f4v/video_file_format_spec_v10_1.pdf)), 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 XXThese 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 (http://imgur.com/a/epVOb).
Does anyone know where these additional bytes come from?
And where they are specified in order to add them programmatically?
Regards,
ceso
FF F1 50 80 XX XX FC 21 XX
It's an ADTS header. I don't know if any software capable of playing raw (header-less, container-less) AAC files.
FF F1 50 80 XX XX FC 21 XX
It's an ADTS header. I don't know if any software capable of playing raw (header-less, container-less) AAC files.
A lot of players should work fine with raw AAC. Mplayer and deadbeef do for sure.
@ceso
Probably won't change anything but add -vn to your command line:
ffmpeg -i video.mp4 -vn -acodec copy audio.aac
how about "audio.mp4" as output?
A lot of players should work fine with raw AAC. Mplayer and deadbeef do for sure.
Thanks to let me know it, but mplayer doesn't seem to play raw AAC in my environment.
Tried with svn-34401 in Windows. [attachment=6820:Light.aac]
I can play this file by generating/adding ADTS header with faad like the following:
faad -a output.adts.aac input.raw.aac.
ffmpeg -i video.mp4 -vn -acodec copy audio.aac
He is saying that output of ffmpeg method (which has ADTS header) is
already playable.
What he was asking is, he has written a program to programmically extract AAC stream from FLV, and couldn't get playable result (This is because it lacks the headers).
He doesn't need to be taught how to use ffmpeg.
Edit: Understood question of TO wrong. Please ignore.
You can use
ffmpeg.exe -i input.aac -acodec copy -absf aac_adtstoasc output.mp4
to convert aac-streams to a valid mp4 container.
And
ffmpeg.exe -i input.flv -acodec copy -vn output.mp4
to convert flv container to mp4 container without video.
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 (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.