29,028
社区成员
发帖
与我相关
我的任务
分享
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// dismissViewController,判断是录制视频省略
NSURL *sourceURL = [[info objectForKey:UIImagePickerControllerMediaURL];
NSURL *newVideoUrl = ........; //一般.mp4
[self convertVideoQuailtyWithInputURL:sourceURL outputURL:newVideoUrl completeHandler:^(AVAssetExportSession *) {
//...........
}];
}
- (void) convertVideoQuailtyWithInputURL:(NSURL*)inputURL
outputURL:(NSURL*)outputURL
completeHandler:(void (^)(AVAssetExportSession*))handler
{
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL opti*****:nil];
AVAssetExportSession *exportSession= [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
exportSession.outputURL = outputURL;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
[exportSessionexportAsynchronouslyWithCompletionHandler:^(void) {
switch (exportSession.status)
{
case AVAssetExportSessionStatusUnknown:
break;
case AVAssetExportSessionStatusWaiting:
break;
case AVAssetExportSessionStatusExporting:
break;
case AVAssetExportSessionStatusCompleted: {
handler(exportSession)
break;
}
case AVAssetExportSessionStatusFailed:
break;
}
}];
}
差不多这样吧,LZ 自己完善吧