我需要在后台执行AVFoundation的sessionVideo.startRunning()以获取冻结用户界面,但是当我在后台执行此操作时,我无法保存视频而我不知道为什么我可以& #39;吨
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
self.sessionVideo.startRunning()
var previewLayer: AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer.layerWithSession(self.sessionVideo) as AVCaptureVideoPreviewLayer
dispatch_async(dispatch_get_main_queue(), {
previewLayer.frame = self.viewCamera.bounds
self.viewCamera.layer.addSublayer(previewLayer)
})
})
录制:
self.fileOutput.startRecordingToOutputFileURL(PathOfTheVideo) , recordingDelegate: self.delegate)
停止并保存:
func stop(){
self.fileOutput.stopRecording()
completion = {reason in println(reason)}
library.writeVideoAtPathToSavedPhotosAlbum(NSURL(PathOfTheVideo), completion)
}
当我尝试保存时,这是零。怎么能正确地做到这一点?
谢谢!