multiple AVAudioRecorder instances

感情迁移 提交于 2020-01-13 13:08:45

问题


i'm working on an app that records sound. furthermore, i want the user to be able to comment certain situations with his own voice. i thought it would be sufficient to configure one audio session and just create two AVAudioRecorder instances with different file URLs. but that doesn't work, the second audio recorder does create its audio file, but it doesn't record any sound.

does anyone know how to realize two AVAudioRecorder instances that actually work on one device?

recording with only one AVAudioRecorder works, but using both doesn't work.

i have a workaround in mind, but that's a bunch of code i would like to avoid at the moment...

thanks!


回答1:


figured the problem out: the audio session is not the problem, it's the audio format.

if you want to record into multiple files using multiple AVAudioRecorders, you have to use uncompressed audio format(s). i assume the HW assisted encoding is used by one AVAudioRecorder and thus every further AVAudioRecorder can't use it simultaniously.

one AVAudioRecorder using a compressed format (e.g. kAudioFormatMPEG4AAC) works fine, but every further recorder has to use an uncompressed audio format. if all AVAudioRecorder instances use a uncompressed format (e.g. kAudioFormatLinearPCM) it also works.



来源:https://stackoverflow.com/questions/8492818/multiple-avaudiorecorder-instances

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