所以我使用AVAudioRecorder錄製AVCaptureSession錄製視頻旁邊的音頻(我知道這很奇怪,但對於我的情況我需要單獨錄製)。AVAudioRecorder無法在iPhone 5S上工作
一切工作正常在每個設備上,除了我的iPhone 5S。它記錄沒有錯誤,但保存到磁盤的文件已損壞或什麼。當我訪問我的Mac上的文件系統並嘗試使用VLC或Quicktime播放m4a文件時,出現「無法檢測到文件格式」錯誤。這裏是我正在初始化我AVAudioRecorder和記錄我的聲音:
// Prepare the audio session
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryRecord error:nil];
[[AVAudioSession sharedInstance] setMode:AVAudioSessionModeVideoRecording error:nil];
// Setup audio recording
NSDictionary *recordSettings = @{AVFormatIDKey: @(kAudioFormatMPEG4AAC),
AVEncoderAudioQualityKey: @(AVAudioQualityLow),
AVEncoderBitRateKey: @16,
AVNumberOfChannelsKey: @1,
AVSampleRateKey: @22050.0f};
NSError *audioRecorderError;
NSURL *audioFileURL = [[self.outputFileURL URLByDeletingPathExtension] URLByAppendingPathExtension:@"m4a"];
self.audioRecorder = [[AVAudioRecorder alloc] initWithURL:audioFileURL
settings:recordSettings
error:&audioRecorderError];
self.audioRecorder.delegate = self;
if (audioRecorderError) {
CCLog(@"Error while initializing the audio recorder... Skipping sound recording!");
}
else {
if (![self.audioRecorder prepareToRecord]) {
CCLog(@"Error preparing to record");
}
if (![self.audioRecorder record]) {
CCLog(@"Error recording");
}
}
再次,這拋開適用於所有設備從5S。任何人都知道可能是由什麼造成的?
你有沒有嘗試過不同的5S以確保它不是你的手機或其操作系統的問題? – HalR
是的,這發生在我測試過的每個5S上。 – codyko
是的,我試過我的5S,它不工作。我的iPad2(ios7)iPhone4(IOS7)運行良好。這真的很奇怪。 – user418751