11

How to record audio as an mp3 file by using AvAudiorecorder? I am using the following code for the recorder setting

recordSetting =  [NSDictionary dictionaryWithObjectsAndKeys:
                  [NSNumber numberWithInt:AVAudioQualityMin],AVEncoderAudioQualityKey,
                  [NSNumber numberWithInt:16], 
                   AVEncoderBitRateKey,
                   [NSNumber numberWithInt: 2], 
                   AVNumberOfChannelsKey,
                   [NSNumber numberWithFloat:44100.0], 
                   AVSampleRateKey, nil];
Sishu
  • 1,510
  • 1
  • 21
  • 48
  • possible duplicate of [How to record an audio file in .mp3 format?](http://stackoverflow.com/questions/4871940/how-to-record-an-audio-file-in-mp3-format) – Brad Larson Apr 26 '12 at 17:32

2 Answers2

12

Add

[NSNumber numberWithInt:kAudioFormatMPEGLayer3] forKey:AVFormatIDKey

However it's impossible to encode mp3 format at IPhone because of royalty.

nostalgia.dl
  • 136
  • 1
  • 3
  • 8
    Thanks for your feedback i used this but i m getting error "Error Domain=NSOSStatusErrorDomain Code=1718449215 "The operation couldn’t be completed. (OSStatus error 1718449215.)" .please provide me complete setting code,if possible,thanks in advance. – Sishu Apr 25 '12 at 12:17
6

Whilst you can play MP3 files using AVAudioPlayer, you can't record in MP3 format with AVAudioRecorder (see this SO post and this SO post). If you need a compressed format, but it doesn't have to be MP3, I suggest recording in AAC format.

Community
  • 1
  • 1