Created
May 10, 2018 19:44
-
-
Save azamsharp/a3d264ffc8dbc1298689966712f77162 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private func startLiveVideo() { | |
session.sessionPreset = AVCaptureSession.Preset.photo | |
let captureDevice = AVCaptureDevice.default(for: AVMediaType.video) | |
let deviceInput = try! AVCaptureDeviceInput(device: captureDevice!) | |
let deviceOutput = AVCaptureVideoDataOutput() | |
deviceOutput.videoSettings = [kCVPixelBufferPixelFormatTypeKey as String: Int(kCVPixelFormatType_32BGRA)] | |
deviceOutput.setSampleBufferDelegate(self, queue: DispatchQueue.global(qos: DispatchQoS.QoSClass.default)) | |
session.addInput(deviceInput) | |
session.addOutput(deviceOutput) | |
let imageLayer = AVCaptureVideoPreviewLayer(session: session) | |
imageLayer.frame = CGRect(x: 0, y: 0, width: self.imageView.frame.size.width + 100, height: self.imageView.frame.size.height) | |
imageLayer.videoGravity = .resizeAspectFill | |
imageView.layer.addSublayer(imageLayer) | |
session.startRunning() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment