2015-11-12 79 views
2

這是我的代碼:AVAssetExportSession出口失敗NSURLErrorDomain代碼 - = 3000(SWIFT)

  startTime = endTime 
      endTime = CMTimeMake(startTime.value + chunkSize, duration!.timescale) 
      if endTime > duration { 
       endTime = duration! 
      } 

      let composition = AVMutableComposition() 
      let videoCompTrack = composition.addMutableTrackWithMediaType(AVMediaTypeVideo, preferredTrackID: CMPersistentTrackID()) 

      let assetVideoTrack: AVAssetTrack = asset!.tracksWithMediaType(AVMediaTypeVideo).first! 

      let chunkDuration = CMTimeSubtract(endTime, startTime) 
      let chunkTimeRange = CMTimeRangeMake(startTime, chunkDuration) 

      do { 
       try videoCompTrack.insertTimeRange(chunkTimeRange, ofTrack: assetVideoTrack, atTime: kCMTimeZero) 

      } catch let error as NSError { 
       print("Video reversing chunking failure: \(error)") 
      } 

      let exportSession = AVAssetExportSession(asset: composition, presetName: preferredPreset) 
      exportSession!.outputURL = chunkURL 
      exportSession!.outputFileType = AVFileTypeQuickTimeMovie 
      exportSession?.shouldOptimizeForNetworkUse = true 

      removeFileAtURLIfExists(chunkURL) 

      exportSession!.exportAsynchronouslyWithCompletionHandler({() -> Void in 
       switch (exportSession!.status) { 
       case AVAssetExportSessionStatus.Completed: 
        NSLog("Export completed") 
       case AVAssetExportSessionStatus.Cancelled: 
        NSLog("Export cancelled") 
        break; 
       default: 
        NSLog("Export failed: \(exportSession?.error)") 
       } 
      }) 

這裏是錯誤消息:

2015年11月13日10:34:24.307 DemFishes [3501:63127]導出失敗: 可選(錯誤域= NSURLErrorDomain代碼= -3000 「無法創建文件」 的UserInfo = {NSLocalizedDescription =無法創建文件, NSUnderlyingError = 0x7ff5ee076460 {錯誤域= NSOSStatusErrorDomain 代碼= -12115「( null)「}})

任何幫助非常感謝,謝謝!

回答

2

發現我的錯誤。 chunkURL不是一個有效的網址

+1

嘿@你可以讓我知道什麼應該是chnkURL嗎?我有同樣的問題。 –

相關問題