7

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

Jonathan Plackett
  • 2,346
  • 2
  • 20
  • 33
  • I am also facing the same issue, have you resolved it yet, please – Himanshu Singla Jun 21 '17 at 10:17
  • "but doesn't make any difference to the framerate in the preview or captured video, which still appears to be full motion." -- Have you checked the codec details to get the frame rate of the recorded video file ? – jpulikkottil May 22 '18 at 08:56

1 Answers1

3

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 =)

fatihyildizhan
  • 8,614
  • 7
  • 64
  • 88
Liam
  • 31
  • 2