I'm new to AVCaptureSession and wish to better understand how to work with it. So I managed capturing the video stream as separated CIImages and convert them to UIImages. Now I wish to be able to get the number of Frames Per Second captured and preferably to be able to set it.
Any idea how to do that?
AVCaptureConnection's videoMinFrameDuration
is deprecated.You can use
AVCaptureDevice
properties to detect supported video frame rate ranges and can assign minimum and maximum frame rates using properties.device.activeFormat.videoSupportedFrameRateRanges
return all video frame rates ranges supported by device.device.activeVideoMinFrameDuration
anddevice.activeVideoMaxFrameDuration
can be used for specifying frame durations.Do it like this
To set the capture session frame rate, you have to set it on the device using device.activeVideoMinFrameDuration and device.activeVideoMaxFrameDuration (if necessary).
In Swift 4 you can do something like this:
And call it
You could use
AVCaptureConnection
'svideoMinFrameDuration
accessor to set the value.See the AVCaptureConnection documentation
Consider
output
beAVCaptureVideoDataOutput
object.More info, see my answer in this SO question