Extract AAC audio data from FLV: Missing headers |
![]() ![]() |
Extract AAC audio data from FLV: Missing headers |
Dec 11 2011, 10:11
Post
#1
|
|
|
Group: Members Posts: 1 Joined: 11-December 11 Member No.: 95735 |
Hi,
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: CODE 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? Regards, ceso |
|
|
|
Dec 11 2011, 12:22
Post
#2
|
|
![]() Group: Developer Posts: 295 Joined: 22-November 10 From: Japan Member No.: 85902 |
|
|
|
|
Dec 30 2011, 21:18
Post
#3
|
|
|
Group: Members Posts: 232 Joined: 28-July 03 From: England, UK Member No.: 8031 |
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 |
|
|
|
Dec 30 2011, 22:48
Post
#4
|
|
![]() A/V Moderator Group: Moderator Posts: 1667 Joined: 30-April 02 From: Slovenia Member No.: 1922 |
how about "audio.mp4" as output?
This post has been edited by smok3: Dec 30 2011, 22:48 -------------------- PANIC: CPU 1: Cache Error (unrecoverable - dcache data) Eframe = 0x90000000208cf3b8
NOTICE - cpu 0 didn't dump TLB, may be hung |
|
|
|
Dec 31 2011, 02:56
Post
#5
|
|
![]() Group: Developer Posts: 295 Joined: 22-November 10 From: Japan Member No.: 85902 |
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: CODE faad -a output.adts.aac input.raw.aac. QUOTE 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. |
|
|
|
Dec 31 2011, 18:45
Post
#6
|
|
|
Group: Members Posts: 9 Joined: 22-July 11 Member No.: 92467 |
Edit: Understood question of TO wrong. Please ignore.
You can use CODE ffmpeg.exe -i input.aac -acodec copy -absf aac_adtstoasc output.mp4 to convert aac-streams to a valid mp4 container. And CODE ffmpeg.exe -i input.flv -acodec copy -vn output.mp4 to convert flv container to mp4 container without video. This post has been edited by Hanseat: Dec 31 2011, 18:50 |
|
|
|
Dec 31 2011, 19:51
Post
#7
|
|
|
Winamp Developer Group: Developer Posts: 662 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. |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 19th June 2013 - 00:45 |