I am trying to set a frame rate of 10 frames per second when capturing with an AVCaptureDevice in Swift.
I believe this is achieved by setting activeVideoMaxFrameDuration of the AVCaptureDevice but maybe I am doing this all wrong and there's a different way.
Here is my current code, which runs without error, but doesn't make any difference to the framerate in the preview or captured video, which still appears to be full motion.
var devices = AVCaptureDevice.devicesWithMediaType(mediaType);
var captureDevice: AVCaptureDevice = devices[0] as AVCaptureDevice;
captureDevice.lockForConfiguration(&error)
captureDevice.activeVideoMinFrameDuration = CMTimeMake(1,10)
captureDevice.activeVideoMaxFrameDuration = CMTimeMake(1,10)
captureDevice.unlockForConfiguration()
I have checked in AVCaptureDeviceFormat videoSupportedFrameRateRanges minFrameRate and 10 frames per second should be supported.
Changing the CMTime to something outside of the videoSupportedFrameRateRanges does throw an error so I know the code is being used, it just has no effect.
Thanks in advance for any help
I think you should change the device configuration after the capture session starts running for it to take effect. I hope this works for you as it did for me. cheers =)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With