iosaudioformataacriff

Reading AAC audio from RIFF container on iOS


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.


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?