How to record audio in iLBC format? I got some help from Question # 1010343 and implemented this code:
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] initWithCapacity:10]; [recordSetting setValue:[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
As above, it works fine. Good record. Simple reproduction. You notice that other formats are commented out. If I try any of them, I wonβt get anything. I want smaller files, and according to Question # 7279643 , which gives this valuable information:
Here are the results for few encoding supported by iPhone: Size of audio file of duration 10 sec. kAudioFormatMPEG4AAC : 164 kB kAudioFormatAppleLossless : 430 kB kAudioFormatAppleIMA4 : 475 kB kAudioFormatULaw : 889 kB kAudioFormatALaw : 889 KB
I must be able to record in iLBC. But if I try, I wonβt get anything. Is there anything else I need to change when recording or playing back when I use a format other than IMA4?
Here is my replay code:
NSError *avError; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryPlayback error:&avError]; [audioSession setActive:YES error:&avError]; if( !avError ) { if( [audioPlayer isPlaying] ) { [audioPlayer stop ]; } while( ![audioPlayer isPlaying] ) { AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFile error:nil]; self.audioPlayer = player; self.audioPlayer.numberOfLoops = 0; [audioPlayer prepareToPlay]; [audioPlayer play]; } } else { NSLog(@"Playback Error: %@", avError ); }
source share