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

11,533

Solution 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.

Solution 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.

Share:
11,533
Vaerenberg
Author by

Vaerenberg

Developing and consulting for iOS and some Android since 2008. Worked on multiple top-selling and featured apps currently available on the App Store.

Updated on June 05, 2022

Comments

  • Vaerenberg
    Vaerenberg almost 2 years

    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.

  • Vaerenberg
    Vaerenberg almost 15 years
    A 3-4 minute caf file would be about 30-40 MB! How can we email such a big file? How does the FourTrack app let user access the wav files using IP address? Thanks for the answer!
  • Vaerenberg
    Vaerenberg almost 15 years
    what about m4a? The new voice memo app included with the 3.0 saves the memos in m4a format. So will the AVAudioRecorder also allow saving .m4a files? Thanks
  • Erich Mirabal
    Erich Mirabal almost 15 years
    typically yes, but not just mp3, or even audio. en.wikipedia.org/wiki/Bit_rate#Bitrates_in_multimedia
  • csakii
    csakii almost 15 years
    developer.apple.com/iphone/library/qa/qa2008/qa1615.html This Q&A talks about recording a compressed CAF file, but doesn't mention m4a as a possibility. If you're recording voice data, one of the listed voice-quality encoders will save a lot of space over uncompressed audio. For high-quality recordings, Apple Lossless will be roughly 50% of the size of uncompressed data.
  • memmons
    memmons over 13 years
    iLBC is good for voice recording. It runs about 7MB for an hour of recording.