【问题标题】:Error Domain=AVFoundationErrorDomain Code=-11814 "Cannot Record"错误域=AVFoundationErrorDomain 代码=-11814 “无法记录”
【发布时间】:2014-06-12 05:00:47
【问题描述】:

它一直给我错误:

错误域=AVFoundationErrorDomain Code=-11814 “无法记录”

我不确定问题是什么?我正在尝试在拍照后计数器达到 1 时立即录制声音。

static int counter;
//counter will always be zero it think unless it is assigned.


if (counter == 0){

dispatch_async([self sessionQueue], ^{
    // Update the orientation on the still image output video connection before capturing.
    [[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] setVideoOrientation:[[(AVCaptureVideoPreviewLayer *)[[self previewView] layer] connection] videoOrientation]];

    // Flash set to Auto for Still Capture
    [AVCamViewController setFlashMode:AVCaptureFlashModeAuto forDevice:[[self videoDeviceInput] device]];

    // Capture a still image.
    [[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:[[self stillImageOutput] connectionWithMediaType:AVMediaTypeVideo] completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {

        if (imageDataSampleBuffer)
        {//[AVCaptureSession snapStillImage];
            NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageDataSampleBuffer];
            UIImage *image = [[UIImage alloc] initWithData:imageData];
            [[[ALAssetsLibrary alloc] init] writeImageToSavedPhotosAlbum:[image CGImage] orientation:(ALAssetOrientation)[image imageOrientation] completionBlock:nil];
        }
        NSLog(@"i");
    }];
});

    if (!_audioRecorder.recording)
{
   //start recording as part of still image

    _playButton.enabled = NO;
    _stopButton.enabled = YES;
    [_audioRecorder record];

    for(int i=0;i<1000;i++)
    {
        //do nothing just counting
    }

    //stop the recording
}

}

else if (counter == 1)

{
    [self recordForDuration:5];
}


}

【问题讨论】:

  • 这是用模拟器吗?
  • @MarkMcCorkle,明白了!
  • 是的,它使用的是模拟器!

标签: ios objective-c avfoundation record


【解决方案1】:

这个错误是因为你使用模拟器,你需要使用设备

问候

【讨论】:

  • 在设备上运行为我修复了它
  • 这发生在我的设备上。
【解决方案2】:

确保只有一个 AVCaptureSession 实例正在运行。

【讨论】:

    【解决方案3】:

    让您的设备在“设置 > 常规 > 限制”下限制相机访问权限也会出现此错误。

    【讨论】:

      【解决方案4】:

      我在 Mac 上使用 Mac Catalyst 应用程序尝试 AVFoundation 时遇到了同样的错误。显然,这是记录在案的预期行为:

      https://forums.developer.apple.com/thread/124652#389519

      https://developer.apple.com/documentation/avfoundation/cameras_and_media_capture

      此问题的行为符合预期。我们确实记录了我们没有列出的文件 Catalyst 模式下的设备。请参阅在 macOS 中运行的重要 iPad 应用程序 不能使用 AVFoundation Capture 类。这些应用程序应该改为 使用 UIImagePickerController 进行照片和视频捕获。

      【讨论】:

        猜你喜欢
        • 2014-11-30
        • 2017-09-15
        • 2018-12-16
        • 2017-07-09
        • 1970-01-01
        • 1970-01-01
        • 2021-12-24
        • 1970-01-01
        • 2011-07-29
        相关资源
        最近更新 更多