compressing a video in iOS
<p>I've looked at <a href="https://stackoverflow.com/questions/5687341/iphoneprogrammatically-compressing-recorded-video-to-share">this question</a> and <a href="https://stackoverflow.com/questions/11751883/how-can-i-reduce-the-file-size-of-a-video-created-with-uiimagepickercontroller">this question</a>, neither have been able to help.</p>

<p>I have tried the following: </p>

<pre><code>- (void)compress:(NSURL *)videoPath completionBlock:(void(^)(id data, BOOL result))block{
    self.outputFilePath = [[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(), @"output.mov"];
    NSURL *outputURL = [NSURL fileURLWithPath:self.outputFilePath];
    [self compressVideoWithURL:self.movieURL outputURL:outputURL handler:^(AVAssetExportSession *exportSession) {

    }];
}

- (void)compressVideoWithURL:(NSURL*)inputURL
                   outputURL:(NSURL*)outputURL
                     handler:(void (^)(AVAssetExportSession*))handler {

    AVURLAsset *asset = [AVURLAsset assetWithURL:self.movieURL];
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality];
    exportSession.fileLengthLimit = 3000000;
    exportSession.outputURL = outputURL;
    exportSession.outputFileType = AVFileTypeQuickTimeMovie;
    exportSession.shouldOptimizeForNetworkUse = YES;
    [exportSession exportAsynchronouslyWithCompletionHandler:^{
        NSData *newOutputData = [NSData dataWithContentsOfURL:outputURL];
        NSLog(@"Size of New Video(bytes):%d",[newOutputData length]);
    }];
}
</code></pre>

<p>I know that <code>self.movieUrl</code> is not <code>nil</code>. But when I printed the size (in bytes) of the <code>NSData</code> associated with the video, they were the same before and after, both 30,000,000 bytes. </p>

<p>But according to <a href="https://stackoverflow.com/questions/5687341/iphoneprogrammatically-compressing-recorded-video-to-share">this question</a>, the above code should work. </p>

<p>What am I doing wrong exactly?</p>