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 AVCaptureConnection
object associated with the AVCaptureVideoDataOutput
object:
AVCaptureConnection *conn = [output connectionWithMediaType:AVMediaTypeVideo];
CMTimeShow(conn.videoMinFrameDuration);
CMTimeShow(conn.videoMaxFrameDuration);
if (conn.isVideoMinFrameDurationSupported)
conn.videoMinFrameDuration = CMTimeMake(1, CAPTURE_FRAMES_PER_SECOND);
if (conn.isVideoMaxFrameDurationSupported)
conn.videoMaxFrameDuration = CMTimeMake(1, CAPTURE_FRAMES_PER_SECOND);
CMTimeShow(conn.videoMinFrameDuration);
CMTimeShow(conn.videoMaxFrameDuration);
If you're using (as I am), the didOutputSampleBuffer
delegate, you can confirm that the video frame rate in the fromConnection
AVCaptureConnection * value passed in to the delegate has been correctly set and "remembered" by the above code.
Note that you need to set both videoMinFrameDuration
and videoMaxFrameDuration
to 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