title: AV Foundation: AVCaptureVideoPreviewLayer and frame duration
body: <p>I am using the AV Foundation to process frames from the video camera (iPhone 4s, iOS 6.1.2). I am setting up AVCaptureSession, AVCaptureDeviceInput, AVCaptureVideoDataOutput per the AV Foundation programming guide. Everything works as expected and I am able to recieve frames in the <code>captureOutput:didOutputSampleBuffer:fromConnection:</code> delegate.</p>
  
  <p>I also have a preview layer set like this:</p>
  
  <pre><code>AVCaptureVideoPreviewLayer *videoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
  [videoPreviewLayer setFrame:self.view.bounds];
  videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
  [self.view.layer insertSublayer:videoPreviewLayer atIndex:0];
  </code></pre>
  
  <p>Thing is, I don't need 30 frames per second in my frame handling and I am not able to process them so fast anyway. So I am using this code to limit the frame duration:</p>
  
  <pre><code>// videoOutput is AVCaptureVideoDataOutput set earlier
  AVCaptureConnection *conn = [videoOutput connectionWithMediaType:AVMediaTypeVideo];
  [conn setVideoMinFrameDuration:CMTimeMake(1, 10)];
  [conn setVideoMaxFrameDuration:CMTimeMake(1, 2)];
  </code></pre>
  
  <p>This works fine and limits the frames recieved by the <em>captureOutput</em> delegate. </p>
  
  <p>However, this also limits the frames per second on the preview layer and preview video becomes  very unresponsive. </p>
  
  <p>I understand from the documentation that the frame duration is set independently on the connection and the preview layer has indeed a different AVCaptureConnection. Checking the mix/max frame durations on <code>[videoPreviewLayer connection]</code> shows that it's indeed set to the defaults (1/30 and 1/24) and different than the durations set on the connection of the AVCaptureVideoDataOutput.</p>
  
  <p>So, is it possible to limit the frame duration only on the frame capturing output and still see a 1/24-1/30 frame duration on the preview video? How?</p>
  
  <p>Thanks.</p>