
见下面的方法:
- (voID) saveVIDeoTolocal:(NSURL *)vIDeoURL { @try { NSArray *documentsDirectory = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES); Nsstring *docPath = [documentsDirectory objectAtIndex:0]; Nsstring *vIDeoname = [Nsstring stringWithFormat:@"sampleVIDeo.mp4"]; Nsstring *vIDeoPath = [docPath stringByAppendingPathComponent:vIDeoname]; NSURL *outputURL = [NSURL fileURLWithPath:vIDeoPath]; NSLog(@"Loading vIDeo"); [self convertVIDeoTolowQuailtyWithinputURL:vIDeoURL outputURL:outputURL handler:^(AVAssetExportSession *exportSession) { if (exportSession.status == AVAssetExportSessionStatusCompleted) { NSLog(@"Compression is done"); } [self performSelectorOnMainThread:@selector(doneCompressing) withObject:nil waitUntilDone:YES]; }]; } @catch (NSException *exception) { NSLog(@"Exception :%@",exception.description); [self performSelectorOnMainThread:@selector(doneCompressing) withObject:nil waitUntilDone:YES]; }}//---------------------------------------------------------------- (voID)convertVIDeoTolowQuailtyWithinputURL:(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:AVAssetExportPresetPassthrough]; exportSession.outputURL = outputURL; exportSession.outputfileType = AVfileTypeMPEG4; [exportSession exportAsynchronouslyWithCompletionHandler:^(voID) { handler(exportSession); }];} 这里我将压缩视频保存到应用程序的文档目录中.您可以在下面的示例代码中查看详细信息:
Sample demo:
总结以上是内存溢出为你收集整理的uiimagepickercontroller – 具有mp4格式的IOS UIImagePicker全部内容,希望文章能够帮你解决uiimagepickercontroller – 具有mp4格式的IOS UIImagePicker所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)