actionscript-3flashaacnetstream

Playing AAC (ADTS) file with Netstream Appendbytes


I want to know if it's really possible to play an AAC (ADTS header) file with Netstream.appendbytes. I'm talking about files that end .aac not AAC audio inside M4A or MP4 containers.

I'm aware Netstream can't parse ADTS headers etc so I already have a class for parsing the data and gives back correct info such as channels, bitrates, framelengths etc.

Putting this together gives silence: Make FLV header (+ append) ->> Make audio tag header (+ append) ->> now append with raw/headerless AAC payload (frame 1) + update previous tag size ->> Make new audio tag for next AAC frame & append ->> raw/headerless payload append (frame 2) and so on until track end.

Can someone please clarify:

I have a lot of questions and a lot research (AAC specs, FLV specs etc) but nothing is helping and there is some confused info on the net (well they don't always speak from an AS3 perspective..). I guess I just need to know it's definitely possible rather than keep on blindly against a technical limitation

PS: I have succesfully played .MP3 audio files with AppendBytes and now changed the process to accomodate AAC (ie: parsing 7 byte header not 4 byte header etc. More to it than that ofcos). Thanks for reading and hope someone out there can help.


Solution

  • I meant to answer this a while back...

    Working Demo.. [ A very basic demo of AAC file playback ] (see below if you need some test AAC file)

    I can happily confirm that it's 100% possible to play an .aac audio file using NetStream. So to clarify my own questions:

    The image below illustrates the process. As you can see after the FLV header & metadata there is tags for BOTH types at first but afterwards its AAC type raw for the rest of the way. No ADTS means remove the 7 byte header from each AAC frame and shove what's left into FLV tags. I made one FLV audio tag per AAC frame (easier to deal with seeking & timestamps etc)...

    enter image description here

    After analysing a test FLV made with FFMPEG inside a Hex editor, I understood to use both settings. I don't how they figured out you needed both instead of either one or other like the FLV Specs (ver 10.1) was suggesting. I bow my head to the genius of those guys & girls.

    I was stuck because of this: enter image description here

    The "Process" image at top is enough for those who know netstream.appendbytes to get on with it:

    If you need some test audio files...

    AAC Loop test 1: (credits: Mark "45" King) - http://goo.gl/U7IuWe
    AAC Loop test 2: (credits: U.T.F.O) - http://goo.gl/W8ieJd
    AAC Extended test: (credits: Enya) - http://goo.gl/EVCy4X