Add the following line
output.minFrameDuration = CMTimeMake(5, 1);
below the comment
// If you wish to cap the frame rate to a known value, such as 15 fps, set
// minFrameDuration.
but above the
[session startRunning];
Edit
Use the following code to preview the camera output.
AVCaptureVideoPreviewLayer *previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:session];
UIView *aView = self.view;
CGRect videoRect = CGRectMake(0.0, 0.0, 320.0, 150.0);
previewLayer.frame = videoRect; // Assume you want the preview layer to fill the view.
[aView.layer addSublayer:previewLayer];
Edit 2:
Ok fine..
Apple has provided a way to set the minFrameDuration here
So now, use the following code to set the frame duration
AVCaptureConnection *conn = [output connectionWithMediaType:AVMediaTypeVideo];
if (conn.supportsVideoMinFrameDuration)
conn.videoMinFrameDuration = CMTimeMake(5,1);
if (conn.supportsVideoMaxFrameDuration)
conn.videoMaxFrameDuration = CMTimeMake(5,1);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…