0
我用這來捕捉圖像如何在iOS(CUSTOM)中捕捉視頻?
var captureDevice : AVCaptureDevice?
var picker = UIImagePickerController()
var captureSession = AVCaptureSession()
var stillImageOutput = AVCaptureStillImageOutput()
var captureVideoPreviewLayer = AVCaptureVideoPreviewLayer()
func captureImage (sender:AnyObject?) {
isCapturingImage = true
var videoConnection :AVCaptureConnection? = nil
for connection:AVCaptureConnection in stillImageOutput.connections as! [AVCaptureConnection] {
for port:AVCaptureInputPort in connection.inputPorts as! [AVCaptureInputPort]{
if(port.mediaType == AVMediaTypeVideo){
videoConnection = connection
break;
}
}
if((videoConnection) != nil) {break}
}
stillImageOutput.captureStillImageAsynchronouslyFromConnection(videoConnection, completionHandler: {
(imageSampleBuffer:CMSampleBufferRef! , error :NSError!) in
if (imageSampleBuffer != nil) {
var imageData = AVCaptureStillImageOutput.jpegStillImageNSDataRepresentation(imageSampleBuffer)
let capturedImage = UIImage.init(data: imageData, scale:1)
}
})
}
我怎樣才能實現捕獲視頻?我幾乎找不到有關自定義視頻捕獲的任何教程。任何人都可以實現捕捉視頻的功能?