我正在尝试编写一个简单的代码来使用 Swift 捕获视频
=====代码=========
override init() {
var err:NSErrorPointer = NSErrorPointer();
camDev = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo);
camSession = AVCaptureSession();
camDevInp = AVCaptureDeviceInput.deviceInputWithDevice(camDev,error: err) as AVCaptureDeviceInput
videoOp = AVCaptureMovieFileOutput();
var paths = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
var documentDir = paths[0] as String;
var fileNamePostfix = 0
do {
filePath = "\(documentDir)/test\(fileNamePostfix++).mp4"
} while (NSFileManager.defaultManager().fileExistsAtPath(filePath))
fileUrlPath = NSURL.fileURLWithPath(filePath)!;
//fileUrlPath = NSURL.fileURLWithPath("\(NSTemporaryDirectory())/testVideo.mov")!
camSession.beginConfiguration();
if(camSession.canAddInput(camDevInp)){
camSession.addInput(camDevInp);
}
if(camSession.canAddOutput(videoOp)){
camSession.addOutput(videoOp);
}
camSession.commitConfiguration();
}
func startCapture() -> Void
{
camSession.startRunning();
videoOp.startRecordingToOutputFileURL(self.fileUrlPath, recordingDelegate: self);
}
===================
调用委托函数 func captureOutput(captureOutput: AVCaptureFileOutput!, didFinishRecordingToOutputFileAtURL outputFileURL: NSURL!, fromConnections connections: [AnyObject]!, error: NSError!) 时出现此错误:Some NSError domain: "AVFoundationErrorDomain" - code: 18446744073709539811 0x0000060800005110