首页 > 移动平台 > 详细

在iOS中,摄像头录制的视频是mov格式的,虽然mov兼容mp4,但是有些需求需要用到mp4格式的视频文件。

时间:2018-05-14 10:48:34      阅读:196      评论:0      收藏:0      [点我收藏+]

技术分享图片

 

AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:path] options:nil]; NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset]; if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality]) { AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetPassthrough]; NSString *exportPath = [NSString stringWithFormat:@"%@/%@.mp4", [NSHomeDirectory() stringByAppendingString:@"/tmp"], @"1"]; exportSession.outputURL = [NSURL fileURLWithPath:exportPath]; NSLog(@"%@", exportPath); exportSession.outputFileType = AVFileTypeMPEG4; [exportSession exportAsynchronouslyWithCompletionHandler:^{ switch ([exportSession status]) { case AVAssetExportSessionStatusFailed: NSLog(@"Export failed: %@", [[exportSession error] localizedDescription]); break; case AVAssetExportSessionStatusCancelled: NSLog(@"Export canceled"); break; case AVAssetExportSessionStatusCompleted: NSLog(@"转换成功"); break; default: break; } }]; }

在iOS中,摄像头录制的视频是mov格式的,虽然mov兼容mp4,但是有些需求需要用到mp4格式的视频文件。

原文:https://www.cnblogs.com/fantasy940155655/p/9034887.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!