Question

I have a file that is a RIFF container with 3 chunks; RIFF chunk has 'WAVE' identifier. First chunk is 'fmt ', second is 'data', the last is 'eink' (my own chunk). So that file is generated by c# code that use directshow. The audio is encoded in AAC. So I wan't to play the audio, that is stored in 'data' chunk, on iOS 5.*.
I've tried to read the whole 'data' chunk and use those bytes in [initWithData:error:][1] method of AVAudioPlayer. But it seems to work differently.
Than I thought, I could try to make my own m4a file with those bytes and play it, but is there any other right way? Please suggest me some ways to investigate it? Where to read? Or other method.

Was it helpful?

Solution

Few concepts regarding WAV, AAC and MP4

WAV is container format, that can store any other audio data, both compressed or uncompressed. More details at http://www.sonicspot.com/guide/wavefiles.html

AAC can be encapsulated in multiple ways. Most common being ADTS and MP4. Details of AAC container format is at http://en.wikipedia.org/wiki/Advanced_Audio_Coding#Container_formats

ADTS is relatively simple format, in which each AAC frame is preceded by a header. More details about ADTS header is at http://wiki.multimedia.cx/index.php?title=ADTS

MP4 is relatively more complex format, with support for storing various audio formats and video formats. In case of MP4, header information is stored once in MP4 structures in the file and rest of AAC frames need not have any header information.

How to support playing WAV file with AAC payload in iOS?

  • Determine the type of payload, whether it is ADTS or MP4 or ADIF
  • If file can be converted offline, use third party libraries like FFMPEG to convert WAV with AAC to M4A file, format supported by iOS.
  • if file need to converted on the device, best method would be to extract the AAC frame data from payload, convert them to way iOS expects and decode it. Best way to determine this would be to convert the file to M4A offline and see how the data is fed to iOS Audio Player.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top