我有一個應用程序在拍攝靜態照片之前創建自己的實時預覽。該應用程序需要對圖像數據執行一些處理,因此無法依賴AVCaptureVideoPreviewLayer。使用Apple的示例代碼,使初始流工作得很好。當我嘗試切換到更高質量的圖像以拍攝快照時,問題就出現了。爲了響應按鈕按下,我嘗試重新配置會話以拍攝全分辨率照片。我嘗試過許多變化,但這裏是我的最新的例子(仍然不工作):如何使用AVCaptureSession傳送實時預覽視頻,然後拍照,然後返回流式傳輸
- (void)sessionSetupForPhoto
{
[session beginConfiguration];
session.sessionPreset = AVCaptureSessionPresetPhoto;
AVCaptureStillImageOutput *output = [[[AVCaptureStillImageOutput alloc] init] autorelease];
for (AVCaptureOutput *output in [session outputs]) {
[session removeOutput:output];
}
if ([session canAddOutput:output]){
[session addOutput:output];
} else {
NSLog(@"Not able to add an AVCaptureStillImageOutput");
}
[session commitConfiguration];
}
我只是commitConfiguration線,看起來像這樣之後我一直收到錯誤消息: (即,我收到發送到我註冊觀察者的AVCaptureSessionRuntimeErrorNotification)
Received an error: NSConcreteNotification 0x19d870 {name = AVCaptureSessionRuntimeErrorNotification; object = ; userInfo = { AVCaptureSessionErrorKey = "Error Domain=AVFoundationErrorDomain Code=-11800 \"The operation couldn\U2019t be completed. (AVFoundationErrorDomain error -11800.)\" UserInfo=0x19d810 {}";
在Xcode中的文檔表面上提供了錯誤號(-11800),更多信息「AVErrorUnknown - 原因的錯誤是未知的。」
此前,我還嘗試過打電話給stopRunning和startRunning,但在觀看WWDC Session 409後不再那樣做,因爲它在那裏不受歡迎。當我停下來並開始時,我收到了一條不同的錯誤消息-11819,它對應於「AVErrorMediaServicesWereReset - 操作無法完成,因爲媒體服務不可用」,比簡單的「未知」更好,但不一定更有幫助。
它成功添加了AVCaptureStillImageOutput(即不發出日誌消息)。
我測試在iPhone 3G(W/4.1)和iPhone 4
該調用在主線程,這也是在那裏我原來AVCaptureSession設置發生發生。
如何避免該錯誤?如何切換到更高分辨率拍攝照片?
謝謝!
我被困在了同樣的錯誤。你找到了解決方法嗎? – 2011-03-10 10:22:04