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

             }

         }];

    }


}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容