从相册中获取到的视频地址 例如 file:///var/mobile/Media/DCIM/100APPLE/IMG_9876.MOV
后面再使用的时候报错 视频文件不存在 那是因为在ios10、11 设备上需要在请求一次权限
PHVideoRequestOptions *options = [[PHVideoRequestOptions alloc] init]; options.networkAccessAllowed = YES; options.version = PHVideoRequestOptionsVersionCurrent; options.progressHandler = ^(double progress, NSError *error, BOOL *stop, NSDictionary *info) { }; //相册中获取到的phAsset; PHAsset *phAsset; //= self.sset; [[PHImageManager defaultManager] requestAVAssetForVideo:phAsset options:options resultHandler:^(AVAsset *asset, AVAudioMix *audioMix, NSDictionary *info) { if(([asset isKindOfClass:[AVComposition class]] && ((AVComposition *)asset).tracks.count == 2)){ //slow motion videos. See Here: https://overflow.buffer.com/2016/02/29/slow-motion-video-ios/ //Output URL of the slow motion file. NSString *root = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject; NSString *tempDir = [root stringByAppendingString:@"/com.sdk.demo/temp"]; if (![[NSFileManager defaultManager] fileExistsAtPath:tempDir isDirectory:nil]) { [[NSFileManager defaultManager] createDirectoryAtPath:tempDir withIntermediateDirectories:YES attributes:nil error:nil]; } NSString *myPathDocs = [tempDir stringByAppendingPathComponent:[NSString stringWithFormat:@"mergeSlowMoVideo-%d.mov",arc4random() % 1000]]; NSURL *url = [NSURL fileURLWithPath:myPathDocs]; //Begin slow mo video export AVAssetExportSession *exporter = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality]; exporter.outputURL = url; exporter.outputFileType = AVFileTypeQuickTimeMovie; exporter.shouldOptimizeForNetworkUse = YES; [exporter exportAsynchronouslyWithCompletionHandler:^{ dispatch_async(dispatch_get_main_queue(), ^{ if (exporter.status == AVAssetExportSessionStatusCompleted) { NSURL *URL = exporter.outputURL; AVURLAsset *asset = [AVURLAsset assetWithURL:URL]; dispatch_async(dispatch_get_main_queue(), ^{ // completion(asset, nil); //拿到有权限的asset }); }else { dispatch_async(dispatch_get_main_queue(), ^{ // 错误 // completion(nil, exporter.error); }); } }); }]; }else { dispatch_async(dispatch_get_main_queue(), ^{ // completion(asset, nil); //拿到有权限的asset }); } }];