Search code examples
iphonexcodeswiftcameraslowmotion

Setting high frame rate recording in Swift


i'm trying to create an app to record video at 120fps but i'm having troubles.

First, when print(device.activeFormat), i get this in the logs

AVCaptureDeviceFormat: 0x13fe49890 'vide'/'420v' 1920x1080, { 2- 30 fps}, fov:58.080, supports vis, max zoom:104.38 (upscales @1.55), AF System:1, ISO:34.0-544.0, SS:0.000024-0.500000

but my device is an iPhone 5s which supports 120fps, don't know why the range here is 2-30fps.

Second, when i do device.activeVideoMaxFrameDuration = CMTimeMake(1, 120) to change the max frame rate to 120 fps, i get this error in the logs:

[AVCaptureVideoDevice setActiveVideoMaxFrameDuration:] - the passed activeVideoMaxFrameDuration 1:120 is not supported by the device.

What am i doing wrong?

Thanks!


Solution

  • As you can see from your print(device.activeFormat), the max support fps is 30 given {2- 30 fps}. Therefore, setting 120 fps with device.activeVideoMaxFrameDuration = CMTimeMake(1, 120) is not supported.