Search code examples
swiftxcodevideophoto

AVCaptureSession.Preset options


Looking over the AVCaptureSession.Preset options, is .photo the only choice for still photos and the rest are all for video capture? What's the difference between .low, .medium and .high and the others like .hd1920x1080? And how do you change the photo size like 4:3 and 16:9? Thanks


Solution

  • It is a bit confusing: AVCaptureSession.Preset doesn't tell you what the photo format or quality will be, it merely tells the AVCaptureSession to configure its inputs and outputs for a specified common use case. So you'd use .photo if you are only interested in photo output, and other modes when you are interested in some video output as well. I believe if you choose .photo and try to add a video output, you will get an error.

    Photo size, much like in real camera, depends on the hardware, you cannot change directly how it's captured. You can, however, change various photo output options using AVCapturePhotoSettings and further process your photo with either Core Graphics or Metal image filters

    I recommend to look at AVCam demo app apple provides, it will answer a lot of these questions.