简体   繁体   English

从iOS上的RIFF容器中读取AAC音频

[英]Reading AAC audio from RIFF container on iOS

I have a file that is a RIFF container with 3 chunks; 我有一个文件,是一个有3个块的RIFF容器; RIFF chunk has 'WAVE' identifier. RIFF块具有“WAVE”标识符。 First chunk is 'fmt ', second is 'data', the last is 'eink' (my own chunk). 第一个块是'fmt',第二个是'data',最后一个是'eink'(我自己的块)。 So that file is generated by c# code that use directshow. 所以该文件是由使用directshow的c#代码生成的。 The audio is encoded in AAC. 音频以AAC编码。 So I wan't to play the audio, that is stored in 'data' chunk, on iOS 5.*. 所以我不想在iOS 5上播放存储在'data'块中的音频。*
I've tried to read the whole 'data' chunk and use those bytes in [initWithData:error:][1] method of AVAudioPlayer . 我试图读取整个'数据'块并在AVAudioPlayer [initWithData:error:][1]方法中使用这些字节。 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? 比我想象的,我可以尝试使用这些字节制作我自己的m4a文件并播放它,但还有其他正确的方法吗? Please suggest me some ways to investigate it? 请建议我一些方法来调查它? Where to read? 在哪里阅读? Or other method. 或其他方法。

Few concepts regarding WAV, AAC and MP4

WAV is container format, that can store any other audio data, both compressed or uncompressed. WAV是容器格式,可以存储压缩或未压缩的任何其他音频数据。 More details at http://www.sonicspot.com/guide/wavefiles.html 有关详细信息, 请访问http://www.sonicspot.com/guide/wavefiles.html

AAC can be encapsulated in multiple ways. AAC可以以多种方式封装。 Most common being ADTS and MP4. 最常见的是ADTS和MP4。 Details of AAC container format is at http://en.wikipedia.org/wiki/Advanced_Audio_Coding#Container_formats AAC容器格式的详细信息请访问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. ADTS是相对简单的格式,其中每个AAC帧前面都有一个标题。 More details about ADTS header is at http://wiki.multimedia.cx/index.php?title=ADTS 有关ADTS标题的更多详细信息, 请访问http://wiki.multimedia.cx/index.php?title=ADTS

MP4 is relatively more complex format, with support for storing various audio formats and video formats. MP4格式相对复杂,支持存储各种音频格式和视频格式。 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. 在MP4的情况下,头文件信息在文件中的MP4结构中存储一次,而其余的AAC帧不需要任何头信息。

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

  • Determine the type of payload, whether it is ADTS or MP4 or ADIF 确定有效载荷的类型,无论是ADTS还是MP4或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. 如果文件可以脱机转换,请使用第三方库(如FFMPEG)将WAV与AAC转换为M4A文件,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. 如果文件需要在设备上转换,最好的方法是从有效载荷中提取AAC帧数据,将它们转换为iOS期望的方式并对其进行解码。 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. 确定这一点的最佳方法是将文件转换为M4A离线,并查看数据如何传送到iOS音频播放器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM