I am currently working on a snippet of code which looks like the following:
if error == nil && (captureSession?.canAddInput(input))!
{
captureSession?.addInput(input)
stillImageOutput = AVCaptureStillImageOutput()
//let settings = AVCapturePhotoSettings()
//settings.availablePreviewPhotoPixelFormatTypes =
stillImageOutput?.outputSettings = [AVVideoCodecKey : AVVideoCodecJPEG]
if (captureSession?.canAddOutput(stillImageOutput))!
{
captureSession?.addOutput(stillImageOutput)
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
previewLayer?.videoGravity = AVLayerVideoGravityResizeAspect
previewLayer?.connection.videoOrientation = AVCaptureVideoOrientation.portrait
cameraView.layer.addSublayer(previewLayer!)
captureSession?.startRunning()
}
}
I am aware that I should be using AVCapturePhotoOutput()
instead of AVCaptureStillImageOutput()
but am confused as to how I can transform the rest of this block if I make that change.
Specifically, how can I apply the same settings using the commented let settings = AVCapturePhotoSettings()
?
For reference, I am using this tutorial as a guide.
Thanks