ios视频格式转换 mp4转mov

#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)