I believe this used to be done with captureOutput.minFrameDuration. However, this is deprecated in iOS 5.
Instead I apparently need to use AVCaptureConnection‘s video.minFrameDuration. So I have my input, my output, I add them both the the capture session – where can I get access to the capture connection? I think it is created for me by the session, but where?
I could try adding the I/O using addInputWithNoConnections and addOutputWithNoConnections and then maybe creating the connection manually. But this seems like a bit of hassle just to set a maximum frame rate. Plus, Xcode complains that these methods don’t exist.
Chris, I think I have solved this problem:
(Edit — See Tomas Camin’s comment below on correct way of checking whether videoMinFrameDuration videoMaxFrameDuration are supported, although below code worked fine when posted)
The line below gives access to the
AVCaptureConnectionobject associated with theAVCaptureVideoDataOutputobject:If you’re using (as I am), the
didOutputSampleBufferdelegate, you can confirm that the video frame rate in thefromConnectionAVCaptureConnection * value passed in to the delegate has been correctly set and “remembered” by the above code.Note that you need to set both
videoMinFrameDurationandvideoMaxFrameDurationto the same value to successfully clamp the frame rate — setting min on its own did not seem to work when testing on an iPhone 4s. This doesn’t seem to be documented.Josh