【发布时间】:2011-10-19 02:55:25
【问题描述】:
我正在使用 AVAudioRecorder 录制音频,但在按下按钮和开始录制之间出现 4 秒延迟。
这是我的设置代码:
NSDictionary *recordSettings = [NSDictionary 字典WithObjectsAndKeys:
[NSNumber numberWithFloat: 16000.0],AVSampleRateKey, [NSNumber numberWithInt: kAudioFormatAppleIMA4],AVFormatIDKey, [NSNumber numberWithInt: 1], AVNumberOfChannelsKey, [NSNumber numberWithInt: AVAudioQualityMax],AVEncoderAudioQualityKey,nil]; NSError *error = nil; audioRecorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL settings:recordSettings error:&error]; if (error) { NSLog(@"error: %@", [error localizedDescription]); } else { NSLog(@"prepare to record"); [audioRecorder prepareToRecord]; }-(void)记录{
NSLog(@"Record"); //[audioRecorder prepareToRecord]; if (!audioRecorder.recording) { NSLog(@"Record 2"); [audioRecorder record]; NSLog(@"Record 3"); }}
记录是按下按钮时调用的函数。我知道 prepareToRecord 是通过“记录”隐式调用的,但我想看看它是否会影响延迟。它没有。
这是控制台日志:
2011-10-18 21:48:06.508 [2949:707] Record
2011-10-18 21:48:06.509 [2949:707] Record 2
2011-10-18 21:48:10.047 [2949:707] Record 3
在开始录制之前大约有 3.5 秒。
这些设置对于 iPhone 来说是不是太多了? (iPhone 4)。我是不是初始化错了?
【问题讨论】:
标签: objective-c audio avaudiorecorder