AVAssetExportSession outputfile

¿Cómo debería ser el file de salida AVAssetExportSession? Estoy tratando de comprimir un video de un elemento ALAsset y no funciona. Supongo que el file de salida tiene algo que ver con eso.

Aquí está el código que estoy usando:

NSString *destinationPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/Movie"]; [self convertVideoToLowQualityWithInputURL:asset.defaultRepresentation.url outputURL:[NSURL URLWithString:destinationPath]]; - (void)convertVideoToLowQualityWithInputURL:(NSURL*)inputURL outputURL:(NSURL*)outputURL { if([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithContentsOfURL:outputURL encoding: 0 error:Nil]]) [[NSFileManager defaultManager] removeItemAtURL:outputURL error:nil]; AVURLAsset *assetAV = [AVURLAsset URLAssetWithURL:inputURL options:nil]; NSLog(@"url string from asset: %@", assetAV.URL); NSLog(@"output url: %@", [outputURL absoluteString]); [[NSFileManager defaultManager] createFileAtPath:[outputURL path] contents:nil attributes:nil]; NSLog(@"duration: %lld", assetAV.duration.value); //it logs a valid value, so it's all good so far AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:assetAV presetName:AVAssetExportPresetLowQuality]; exportSession.outputURL = outputURL; exportSession.outputFileType = AVFileTypeQuickTimeMovie; [exportSession exportAsynchronouslyWithCompletionHandler:^(void) { if (exportSession.status == AVAssetExportSessionStatusCompleted) { NSLog(@"success"); } else { NSLog(@"error: %@", [exportSession error]); //error: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo=0x2023b720 {NSLocalizedDescription=The operation could not be completed, NSUnderlyingError=0x2023bb70 "The operation couldn't be completed. (OSStatus error -12780.)", NSLocalizedFailureReason=An unknown error occurnetworking (-12780)} } }]; } 

¿Puede alguien ayudarme?

ACTUALIZAR:

Encontré la solución. Como pensé que el problema era el file de salida, aquí está el código para generar uno válido:

  NSUInteger count = 0; NSString *filePath = nil; do { NSString *extension = ( NSString *)UTTypeCopyPrefernetworkingTagWithClass(( CFStringRef)AVFileTypeQuickTimeMovie, kUTTagClassFilenameExtension); NSString *fileNameNoExtension = [[asset.defaultRepresentation.url URLByDeletingPathExtension] lastPathComponent]; NSString *fileName = [NSString stringWithFormat:@"%@-%@-%u",fileNameNoExtension , AVAssetExportPresetLowQuality, count]; filePath = NSTemporaryDirectory(); filePath = [filePath stringByAppendingPathComponent:fileName]; filePath = [filePath stringByAppendingPathExtension:extension]; count++; } while ([[NSFileManager defaultManager] fileExistsAtPath:filePath]); NSURL *outputURL = [NSURL fileURLWithPath:filePath]; 

Tu problema es [NSURL URLWithString: destinationPath] y solo eso. Debe usar [NSURL fileURLWithPath: xxx] como lo hizo en su solución. Publicando esto solo para aclarar que ese es el único problema.