2015-11-25 18 views
5

を作成することはできません。ファイル:///民間これは私の同僚のデバイス上で正常に動作します、しかし、それは私のiPadエア2(iOSの9.1)と同様に、私たちのQAのiPadミニ3.AVAssetExportSessionは、私はいつもこのエラーが発生します何らかの理由でファイルエラー-12115

- (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; 
     } 
    }]; 
} 

ソースのURLに毎回失敗します/var/mobile/Containers/Data/Application/BD85BA54-5B3D-4533-A142-C2A30F373814/tmp/capture-T0x12fe1e8e0.tmp.CbksL4/capturedvideo.MOV

出力URL:ファイル:/// VAR /モバイル/コンテナ/データ/アプリケーション/ BD85BA54-5B3D-4533-A142-C2A30F373814 /ライブラリ/ファイル/ 59124681-ba1a-4453-8078-9ca6ac3088bf /添付ファイル/ 454dd782-6b14-44cd-9f4e-84664908388b

私は、ファイルを追加してみました拡張子(.mp4)を出力URLにdは助けになりませんでした。私はこのシナリオにはまったくマッチしないものを探しました。

+0

これを解決しましたか? –

+0

出力URLのファイル拡張子が.mp4であることを確認してください。 – dmclean

+0

Macの場合、viaのようなファイルに書き込む権限があることを確認してください(Sandboxが書き込みアクセスを許可しない可能性があります):BOOL isWritable = [[NSFileManager defaultManager] isWritableFileAtPath:outputURL.path]; \t NSLog(@ "は書き込み可能です:%@"、@(isWritable)); – Karsten

答えて

0

出力URLのパスの末尾に.mp4というファイル拡張子が付いていることを確認してください。

関連する問題