title: Exporting AVCaptureSession video in a size that matches the preview layer
body: <p>I'm recording video using <code>AVCaptureSession</code> with the session preset <code>AVCaptureSessionPreset640x480</code>. I'm using an <code>AVCaptureVideoPreviewLayer</code> in a non-standard size (300 x 300) with the gravity set to aspect fill while recording. It's setup like this:</p>
  
  <pre><code>self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:_captureSession];
  _previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
  _previewLayer.frame = _previewView.bounds; // 300 x 300
  [_previewView.layer addSublayer:_previewLayer];
  </code></pre>
  
  <p>After recording the video, I want to write it to a file in quicktime format. During playback, I'm once again playing the video in a 300 x 300 non-standard size layer. Because these videos will ultimately be transferred over a network connection, it seems wasteful to keep the full 640x480 video.</p>
  
  <p>What's the best way to export a video to match my 300 x 300 preview layer? I'm an AVFoundation noob, so if I'm going about this the wrong way please let me know. I just want the recorded video displayed in the preview layer during recording to match the video that is exported on disk.</p>