如何减less手机上通过我的iOS应用程序录制的video的文件大小

我正在制作iOS应用程序(即将推出Android),其中涉及用户通过应用程序在手机上录制video。 但我需要的应用程序来减less这些video的默认大小,以便当他们上传到我的服务器使用较less的带宽,并上传得更快。 什么是最好的方法来做到这一点?

试试这个代码,希望你的任务完成。

- (void)convertVideoToLowQuailty:(NSURL*)inputURL outputURL:(NSURL*)outputURL handler:(void (^)(AVAssetExportSession*))handler { [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil]; AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil]; AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetLowQuality]; exportSession.outputURL = outputURL; exportSession.outputFileType = AVFileTypeQuickTimeMovie; [exportSession exportAsynchronouslyWithCompletionHandler:^(void) { handler(exportSession); [exportSession release]; }]; } - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL]; NSURL *outputURL = [NSURL fileURLWithPath:@"/Users/Hems/Desktop/output.mov"]; [self convertVideoToLowQuailty:videoURL outputURL:outputURL handler:^(AVAssetExportSession *exportSession) { if (exportSession.status == AVAssetExportSessionStatusCompleted) { printf("completed\n"); } else { printf("error\n"); } }]; }