Error Domain=AVFoundationErrorDomain Code=-11800 “The operation could not be completed” {Error Domain=NSOSStatusErrorDomain Code=-16976 “(null)”}

梦想的初衷 提交于 2019-12-02 05:45:25

I had the exact same error and only on the iPhone 5S simulator running iOS11. I fixed it by changing the quality setting on the export operation from "Highest" (AVAssetExportPresetHighestQuality) to "Pass through" (AVAssetExportPresetPassthrough) (keeping original quality):

/// try to start an export session and set the path and file type
    if let exportSession = AVAssetExportSession(asset: mixComposition, presetName: AVAssetExportPresetPassthrough) { /* AVAssetExportPresetHighestQuality */
      exportSession.outputURL = videoOutputURL
      exportSession.outputFileType = AVFileType.mp4
      exportSession.shouldOptimizeForNetworkUse = true

      exportSession.exportAsynchronously(completionHandler: {
        switch exportSession.status {
        case .failed:
          if let _error = exportSession.error {
            // !!!used to fail over here with 11800, -16976 codes, if using AVAssetExportPresetHighestQuality.  But works fine when using:  AVAssetExportPresetPassthrough
            failure(_error)
          }
          ....

Hope this helps someone, because that error code and message doesn't provide any information. It's just an "Unknown error". Besides changing the quality setting, I would try changing other settings and stripping down the export operation to identify a specific component of that operation that may be failing. (Some specific image, audio or video asset). When you have such a general error message, it's good to use the process of elimination, cutting the code in half each time, to get to the problem in Logarithmic time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!