Search code examples
iphonerecordavaudiorecorder

How to record audio as mp3 file by using AvAudiorecorder in iOS


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];

Solution

  • Add

    [NSNumber numberWithInt:kAudioFormatMPEGLayer3] forKey:AVFormatIDKey
    

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