ios exportAsynchronouslyWithCompletionHandler NSErrorFailingURLKey

时间:2012-12-18 14:48:30

标签: iphone ios cocoa-touch avassetexportsession

我正在使用AVAssetExportSession和AVURLAsset 还有与之相关的图书馆。

我的代码是

NSData *data = [NSData dataWithContentsOfURL:movieUrl];
            NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

            NSString  *documentsDirectory = [paths objectAtIndex:0];
           NSString *path = [NSString stringWithFormat:@"%@/%@", documentsDirectory,@"capturedvideo1.MOV"];
            NSURL *url = [NSURL URLWithString:path];
            [data writeToFile:path atomically:YES];
                       //Delete the original asset
            NSArray *paths1 = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

            NSString  *documentsDirectory1 = [paths1 objectAtIndex:0];
            NSString *path1 = [NSString stringWithFormat:@"%@/%@", documentsDirectory1,@"capturedvideo11.MOV"];
            NSURL *url1 = [NSURL URLWithString:path1];

            [self convertVideoToLowQuailtyWithInputURL:url outputURL:url1 handler:Nil];

- (void)convertVideoToLowQuailtyWithInputURL:(NSURL*)inputURL
                                   outputURL:(NSURL*)outputURL
                                     handler:(void (^)(AVAssetExportSession*))handler

{

    AVURLAsset *asset = [AVURLAsset URLAssetWithURL:inputURL options:nil];
    AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetMediumQuality];
    exportSession.outputURL = outputURL;
    if ([[UIApplication sharedApplication]canOpenURL:inputURL]){
        NSLog(@"open");
    }
    exportSession.outputFileType = AVFileTypeQuickTimeMovie;
    NSLog(@"%@", exportSession.error);
    [exportSession exportAsynchronouslyWithCompletionHandler:^(void)
     {
         if(exportSession.status != AVAssetExportSessionStatusCompleted){
             NSLog(@"%@", exportSession.error);
         }

     }];
}

但我正在低于错误

    Error Domain=NSURLErrorDomain Code=-1 "unknown error" UserInfo=0x1da3aed0 
NSErrorFailingURLStringKey=/var/mobile/Applications/6EF91ECE-9E7A-4019-9F07-6DFE028EFFEA/Documents
/capturedvideo1.MOV, NSErrorFailingURLKey=/var/mobile/Applications/6EF91ECE-
9E7A-4019-9F07-6DFE028EFFEA/Documents/capturedvideo1.MOV, NSLocalizedDescription=unknown error, 
NSUnderlyingError=0x1da3ef70 "The operation couldn’t be completed. (OSStatus error -12935.)",
 NSURL=/var/mobile/Applications/6EF91ECE-9E7A-4019-9F07-6DFE028EFFEA/Documents/capturedvideo1.MOV}

我想减少视频文件的大小。该视频质量很高。

0 个答案:

没有答案