Question

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:

  • In the FLV tag we put extra byte to specify whether Raw or Sequenced AAC type. If I have removed the 7 byte header and left with only data up the next frame/SyncWord. I assume its Raw but I get silence whichever setting I choose. Should I be considering anything else (ie an additional function depending on type?)

  • Should AAC header bytes exist in some data at some point sent to the Appendbytes command? Even if I already set FLV tag to Raw AAC audio?

  • Do all AAC files hold 1024 samples per frame regardless of channels or should I multiply 1024 by channels number? I ask because I need this for correct duration calculation and noticed when testing MP3s that I get silence if duration or framelengths are wrong.

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.

Was it helpful?

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:

  • You need both AAC types mentioned at first to kickstart the AAC decoder then afterwards you can do the usual FLV tag with AAC type: Raw + Raw AAC data (no ADTS header) and continue as such until track end.

  • Nope. No ADTS bytes should be sent to the Netstream decoder.

  • Yes every AAC frame contains 1024 samples and each frame is equal to 23.21 milisecs (around 44 frames for 1 second of audio). Channel settings are irrelevant.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top