在iOS中,摄像头录制的视频是mov格式的,虽然mov兼容mp4,但是有些需求需要用到mp4格式的视频文件。
2016-05-04 14:31
831 查看
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开发------获取iPhone的具体型号
- 大牛博客源
- iOS开发之XIB中Cell出现警告的消除方法
- iOS~runtime初览
- ios 定位提示 现实之后立马消失解决之道
- IOS开发之——登录加密也许用到的,反转字符串
- iOS监控系统音量 手机音量
- iOS多线程
- iOS开发 ☞ AFNetWorking
- iOS 控制系统的音量改变
- iOS中利用 runtime 一键改变字体
- IOS全屏左侧滑(系统方法)
- iOS之JS交互
- iOS 取得ipa里面的图片
- 判断 iOS wifi 是否打开
- iOS 毛玻璃
- Runtime方法的使用—Protocol、SEL篇
- iOS tableView分组
- iOS开发中如何自定义tableView的分割线
- iOS开发之自定义AlertView