MOV转MP4格式

来源:互联网 发布:countdown.js 下载 编辑:程序博客网 时间:2024/05/13 02:55
AVURLAsset *avAsset = [AVURLAsset URLAssetWithURL:[[fieldData objectAtIndex:0]objectForKey:@"videopath"] options:nil];    NSArray *compatiblePresets = [AVAssetExportSession exportPresetsCompatibleWithAsset:avAsset];        if ([compatiblePresets containsObject:AVAssetExportPresetLowQuality])            {        NSDateFormatter *formatter =[[NSDateFormatter alloc]init];        [formatter setDateFormat:@"yyyyMMddHHmmss"];        videoNameStr =[NSString stringWithFormat:@"%@",[formatter stringFromDate: [NSDate date]]];                AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]initWithAsset:avAsset presetName:AVAssetExportPresetPassthrough];        exportPath = [NSString stringWithFormat:@"%@/%@.mp4",                      [NSHomeDirectory() stringByAppendingString:@"/tmp"],                      videoNameStr];        exportSession.outputURL = [NSURL fileURLWithPath:exportPath];        exportSession.outputFileType = AVFileTypeMPEG4;        url = [NSURL fileURLWithPath:exportPath];        [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;            }        }];    }


其中url 为转换后的存贮地址


0 0
原创粉丝点击