美文网首页
ios视频格式转换 mp4转mov

ios视频格式转换 mp4转mov

作者: 飞行的理想 | 来源:发表于2019-02-11 11:44 被阅读0次

#pragma mark - mp4转mov

+ (void)mp4ChangeMovInMp4File:(NSURL*)mp4Fle block:(void(^)(NSURL*file))block

{

//    NSURL *input = [self getSandxAddressUrl:mp4Fle];

    AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:mp4Fle options:nil];

    NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset];

    if ([compatiblePresets containsObject:AVAssetExportPresetMediumQuality]) {

        AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:avAsset presetName:AVAssetExportPresetMediumQuality];

        NSString *str = [NSString stringWithFormat:@"movie.mov"];

        if ([[NSFileManager defaultManager]fileExistsAtPath:[self getSandxAdressInfile:str]]) {

            [[NSFileManager defaultManager] removeItemAtPath:[self getSandxAdressInfile:str] error:nil];

        }

        exportSession.outputURL= [selfgetSandxAddressUrl:str];

        exportSession.outputFileType = @"com.apple.quicktime-movie";

        exportSession.shouldOptimizeForNetworkUse = YES;

        [exportSessionexportAsynchronouslyWithCompletionHandler:^(void){

             if (exportSession.status == AVAssetExportSessionStatusCompleted) {

                 block(exportSession.outputURL);

             }else if (exportSession.status == AVAssetExportSessionStatusFailed){

                 NSLog(@"mp4转mov失败%@",exportSession.error);

                 block(nil);

             }

         }];

    }

}

相关文章

网友评论

      本文标题:ios视频格式转换 mp4转mov

      本文链接:https://www.haomeiwen.com/subject/fcfqeqtx.html