How to record using AVAudioRecorder without the .caf container?

只愿长相守 提交于 2019-12-04 12:39:36

问题


I am using a AVAudioRecorder instance to record with the setting for AVFormatIDKey set to kAudioFormatMPEG4AAC. It records the audio in AAC format but a .caf audio container packages the audio file. (I can see the caff header in the recorder file). How do I record so that the caff container is not there but in pure m4a format so that I can use the files across platforms.


回答1:


Found the answer. There is a weird way the AVAudioRecorder works.

The format in which the AVAudioRecorder will save your file depends on the URL/string you specify for the file you save. It depends on the extension of the file name you are saving.

If you don't specify any extension or one that the recorder can't understand then it will add the Core Audio container. So, basically see to that the extension and the AVFormatIDKey match. Like for aac use format use .aac extension with kAudioFormatMPEG4AAC as the AVFormatIDKey



来源:https://stackoverflow.com/questions/11170517/how-to-record-using-avaudiorecorder-without-the-caf-container

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!