我正在实施音频录制。它可以很好地与caf
& wave
格式。但问题是文件大小太大。iOS:音频录制文件格式
那么,任何人都可以帮助我记录音频格式,也发挥在窗口&文件大小是低的。
我尝试的代码如下:
dirPaths = NSSearchPathForDirectoriesInDomains(
NSDocumentDirectory, NSUserDomainMask, YES);
docsDir = [dirPaths objectAtIndex:0];
NSString *soundFilePath = [docsDir
stringByAppendingPathComponent:@"sound.wave"];
NSLog(@"%@",soundFilePath);
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
NSDictionary *recordSettings = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:AVAudioQualityMin],
AVEncoderAudioQualityKey,
[NSNumber numberWithInt:16],
AVEncoderBitRateKey,
[NSNumber numberWithInt: 2],
AVNumberOfChannelsKey,
[NSNumber numberWithFloat:8000.0], AVSampleRateKey,
[NSNumber numberWithInt:8], AVLinearPCMBitDepthKey,
nil];
NSError *error = nil;
audioRecorder = [[AVAudioRecorder alloc]
initWithURL:soundFileURL
settings:recordSettings
error:&error];
if (error)
{
NSLog(@"error: %@", [error localizedDescription]);
} else {
[audioRecorder prepareToRecord];
}
重复http://stackoverflow.com/questions/4279311/how-to-record-voice-in-m4a-format? – nneonneo
以m4a(MPEG-4 AAC)格式录制。有关详细信息,请参阅http://stackoverflow.com/questions/4279311/how-to-record-voice-in-m4a-format。 – nneonneo