2015-11-25 14 views
5

Đối với một số lý do tôi luôn nhận được lỗi này:AVAssetExportSession Không thể tạo tập tin Lỗi -12.115

Error Domain=NSURLErrorDomain Code=-3000 "Cannot create file" UserInfo={NSLocalizedDescription=Cannot create file, NSUnderlyingError=0x1321dd730 {Error Domain=NSOSStatusErrorDomain Code=-12115 "(null)"}}

khi cố gắng để xuất khẩu một AVSession sang m4a. Đây hoạt động tốt trên thiết bị đồng nghiệp của tôi, tuy nhiên nó không thành công mỗi lần trên iPad của tôi Air 2 (iOS 9.1), cũng như bảo đảm chất lượng iPad Mini của chúng tôi 3.

- (void)processSourceVideoFile:(NSURL *)mediaURL completion:(void (^)(BOOL success))completion { 
    [self showProgressOverlay]; 

    NSString *outputFileType = AVFileTypeMPEG4; 

    __block NSString *videoID = nil; 
    if (self.videoAttachment == nil) { 
     [MagicalRecord saveUsingEditContextWithBlockAndWait:^(NSManagedObjectContext *localContext) { 
      self.videoAttachment = [SPXAttachment MR_createEntityInContext:localContext]; 
      self.videoAttachment.uuid = [NSString uuid]; 
      self.videoAttachment.clientCreatedAt = [NSDate date]; 
      videoID = self.videoAttachment.uuid; 
     }]; 
    } else { 
     videoID = self.videoAttachment.uuid; 
    } 

    self.videoAttachment = [SPXAttachment MR_findFirstByAttribute:@"uuid" withValue:videoID]; 

    NSString *targetPath = self.videoAttachment.filePath; 
    DDLogVerbose(@"Exporting Video to %@", targetPath); 
    if ([[NSFileManager defaultManager] fileExistsAtPath:targetPath]) { 
     [[NSFileManager defaultManager] removeItemAtPath:targetPath error:nil]; 
    } 

    AVAsset *video = [AVAsset assetWithURL:mediaURL]; 

    self.exportSession = [AVAssetExportSession exportSessionWithAsset:video presetName:AVAssetExportPreset640x480]; 
    self.exportSession.outputFileType = outputFileType; 
    self.exportSession.outputURL = [NSURL fileURLWithPath:targetPath]; 

    [self.exportSession exportAsynchronouslyWithCompletionHandler:^{ 

     dispatch_async(dispatch_get_main_queue(), ^{ 
      [self hideProgressOverlay]; 
     }); 

     switch (self.exportSession.status) { 
      case AVAssetExportSessionStatusFailed: 
       DDLogError(@"Video Export Failed: %@", self.exportSession.error); 
       completion(NO); 
       break; 
      case AVAssetExportSessionStatusCancelled: 
       DDLogVerbose(@"Video Export Cancelled"); 
       break; 
      case AVAssetExportSessionStatusCompleted: { 
       DDLogVerbose(@"Video Export Complete for %@", targetPath); 
       BOOL dir; 
       if ([[NSFileManager defaultManager] fileExistsAtPath:targetPath isDirectory:&dir]) { 
        DDLogVerbose(@"FILE IS THERE MOFO!!"); 
       } 
       completion(YES); 
      } 
       break; 
      default: 
       break; 
     } 
    }]; 
} 

Nguồn URL: file: /// tin /var/mobile/Containers/Data/Application/BD85BA54-5B3D-4533-A142-C2A30F373814/tmp/capture-T0x12fe1e8e0.tmp.CbksL4/capturedvideo.MOV

URL đầu ra: file: /// var/mobile/container/dữ liệu/ứng dụng/BD85BA54-5B3D-4533-A142-C2A30F373814/Library/Files/59.124.681-ba1a-4453-8078-9ca6ac3088bf/file đính kèm/454dd782-6b14-44cd-9f4e-84664908388b

tôi đã cố gắng thêm một tập tin tiện ích mở rộng (.mp4) đến URL đầu ra d không giúp được gì. Tôi đã tìm kiếm xung quanh không có gì hoàn toàn phù hợp với kịch bản này.

Bất kỳ trợ giúp nào được đánh giá cao!

+0

Bạn đã giải quyết vấn đề này chưa? –

+0

Đảm bảo rằng URL đầu ra của bạn có đuôi tệp .mp4. – dmclean

+0

Trên máy Mac, hãy đảm bảo bạn có quyền ghi vào tệp như thông qua (Sandbox có thể không cho phép ghi quyền truy cập): BOOL isWritable = [[NSFileManager defaultManager] isWritableFileAtPath: outputURL.path]; \t NSLog (@ "có thể ghi:% @", @ (isWritable)); – Karsten

Trả lời

0

Đảm bảo rằng đường dẫn URL của URL đầu ra của bạn có đuôi tệp .mp4 ở cuối.

Các vấn đề liên quan