错误域= AVFoundationErrorDomain代码= -11814"无法记录"

时间:2014-06-12 05:00:48

标签: ios objective-c avfoundation record

它不断给我错误:

  

错误域= AVFoundationErrorDomain代码= -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];
}


}

4 个答案:

答案 0 :(得分:2)

此错误是因为您使用模拟器,您需要使用设备

此致

答案 1 :(得分:2)

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

答案 2 :(得分:1)

确保只有private static List<ColDef<BauwerkOption, IColDefValue<?>>> DEF = new ArrayList<>(); 个实例正在运行。

答案 3 :(得分:0)

在Mac上使用Mac Catalyst应用程序尝试AVFoundation时遇到了相同的错误。这是有据可查的和预期的行为,

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

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

此问题的行为符合预期。我们确实记录了没有列出的信息 催化剂模式下的设备。查看在macOS中运行的重要iPad应用 无法使用AVFoundation Capture类。这些应用应改为 使用UIImagePickerController进行照片和视频捕获。