title: How can I reduce the file size of a video created with UIImagePickerController?
body: <p>I have an app that allows a user to record a video with <code>UIImagePickerController</code> and then upload it to YouTube. The problem is that the video file that <code>UIImagePickerController</code> creates is HUGE, even when the video is only 5 seconds long. For example, a 5 second long video is 16-20 megabytes. I want to keep the video in 540 or 720 quality, but I want to reduce the file size.</p>
  
  <p>I've been experimenting with AVFoundation and <code>AVAssetExportSession</code> to try to get a smaller file size. I've tried the following code:</p>
  
  <pre><code>AVAsset *video = [AVAsset assetWithURL:videoURL];
  AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:video presetName:AVAssetExportPresetPassthrough];
  exportSession.shouldOptimizeForNetworkUse = YES;
  exportSession.outputFileType = AVFileTypeMPEG4;
  exportSession.outputURL = [pathToSavedVideosDirectory URLByAppendingPathComponent:@"vid1.mp4"];
  [exportSession exportAsynchronouslyWithCompletionHandler:^{
      NSLog(@"done processing video!");
  }];
  </code></pre>
  
  <p>But <strong>this hasn't reduced the file size at all</strong>. I know what I'm doing is possible because in Apple's Photos app, when you select <strong>"share on YouTube"</strong>, will automatically process the video file so its small enough to upload. I want to do the same thing in my app. </p>
  
  <p>How can I accomplish this?</p>