iPhone - AVAudioRecorder - how can I record to an mp3?

江枫思渺然 提交于 2019-11-29 16:15:02

问题


I am using the AVAudioRecorder class available with the 3.0 SDK to record audio in my app. I am successfully able to record to a caf/aiff file. But I would like to record to an mp3.

I tried changing some values in the settings dictionary but all I get is a blank file.

  1. Is it possible to record to an mp3 using AVAudioRecorder

  2. If not, how can I transfer the caf files from my app to a computer?

Thanks.


回答1:


From all I can find on the API documentation, you can't change the encoder. The only encoder settings I could find that you can change are:

AVEncoderAudioQualityKey;
AVEncoderBitRateKey;
AVEncoderBitDepthHintKey;

As for transferring the file, a typical approach would be to email the file.




回答2:


See:

http://developer.apple.com/iphone/library/qa/qa2008/qa1615.html

IMA is a 4:1 format, which means it will compress to 25% of the original size. It's good enough for voice, but not ideal for music.

Lossless is great for music, but usually only gets 50%.

µLaw and aLaw are older formats that compress to 50%, but are much worse than Lossless.

I haven't used iLBC.

I'd bet you'll never see an MP3 encoder made available to third-party apps due to licensing issues.




回答3:


You'll have to include your own MP3 encoder. And you might not be able to do the encoding in real-time. Sad, but there it is.



来源:https://stackoverflow.com/questions/1052092/iphone-avaudiorecorder-how-can-i-record-to-an-mp3

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