title: Change the bitrate of recordings made with AVFoundation on Mac
body: <p>I'm doing some screen recording on the OSX 10.8 with AVFoundation. I'm using the sessionPreset "AVCaptureSessionPresetPhoto" to record the entire screen. One thing I'd like to change is the quality of the movie file that is created.</p>
  
  <p>AVCaptureSessionPresetPhoto seems to be required to actually capture the full screen without clipping.</p>
  
  <p>According to the documentation here: <a href="http://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html" rel="nofollow">http://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html</a></p>
  
  <pre><code>"You use this property to customize the quality level or bitrate of the output. For possible values of sessionPreset, see “Video Input Presets.” The default value is AVCaptureSessionPresetHigh."
  </code></pre>
  
  <p>However, for Video Input Presets, the only options are these constants:
  <a href="http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html#//apple_ref/occ/cl/AVCaptureSession" rel="nofollow">http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html#//apple_ref/occ/cl/AVCaptureSession</a></p>
  
  <pre><code>NSString *const AVCaptureSessionPresetPhoto;
  
  NSString *const AVCaptureSessionPresetHigh;
  
  NSString *const AVCaptureSessionPresetMedium;
  
  NSString *const AVCaptureSessionPresetLow;
  
  NSString *const AVCaptureSessionPreset320x240;
  
  NSString *const AVCaptureSessionPreset352x288;
  
  NSString *const AVCaptureSessionPreset640x480;
  
  NSString *const AVCaptureSessionPreset960x540;
  
  NSString *const AVCaptureSessionPreset1280x720;
  </code></pre>
  
  <p>AVCaptureSessionPresetPhoto does the work of capturing the full screen without clipping, but the final quality is somewhat underwhelming. There are visible artifacts due to the lower bitrate that is used by default.</p>
  
  <p>How can I go about increasing the bitrate of the final recording?</p>
  
  <p>Below is a sample of my current code.</p>
  
  <pre><code>    mSession = [[AVCaptureSession alloc] init];
  
      mSession.sessionPreset = AVCaptureSessionPresetPhoto;
  
      CGDirectDisplayID displayId = kCGDirectMainDisplay;
  
      AVCaptureScreenInput *input = [[AVCaptureScreenInput alloc] initWithDisplayID:displayId];
      if (!input) {
          mSession = nil;
          return;
      }        
  
      if ([mSession canAddInput:input]){
          [mSession addInput:input];
      }
  
      mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
      if ([mSession canAddOutput:mMovieFileOutput])
          [mSession addOutput:mMovieFileOutput];
  
      [mSession startRunning];
  
      if ([[NSFileManager defaultManager] fileExistsAtPath:[destPath path]])
      {
          NSError *err;
          if (![[NSFileManager defaultManager] removeItemAtPath:[destPath path] error:&amp;err])
          {
              NSLog(@"Error deleting existing movie %@",[err localizedDescription]);
          }
      }
  
      [mMovieFileOutput startRecordingToOutputFileURL:destPath recordingDelegate:self];
  
      mTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(finishRecord:) userInfo:nil repeats:NO];
  </code></pre>