【问题标题】:Why does AVSampleBufferDisplayLayer fail with Operation Interrupted (-11847)?为什么 AVSampleBufferDisplayLayer 因操作中断 (-11847) 而失败?
【发布时间】:2015-03-03 21:07:15
【问题描述】:

我正在使用AVSampleBufferDisplayLayer 来解码和显示从服务器流式传输的 H.264 视频。当我的应用程序进入后台然后返回前台时,解码过程被搞砸了,AVSampleBufferDisplayLayer 失败。我看到的错误是:

H.264 decoding layer has failed: Error Domain=AVFoundationErrorDomain
  Code=-11847 "Operation Interrupted" UserInfo=0x17426c500
  {NSUnderlyingError=0x17805fe90 "The operation couldn’t be completed.
    (OSStatus error -12084.)",
   NSLocalizedRecoverySuggestion=Stop other operations and try again.,
   NSLocalizedDescription=Operation Interrupted}

还有其他人在AVSampleBufferDisplayLayer 上遇到过类似的问题吗?这是什么意思?

当我收到错误时,我尝试销毁AVSampleBufferDisplayLayer 并创建一个新的,但随后我开始收到来自 H.264 解码器的其他错误:

Error Domain=AVFoundationErrorDomain Code=-11821 "Cannot Decode"
UserInfo=0x1740e9700 {AVErrorMediaSubTypeKey=(1635148593),
  NSLocalizedFailureReason=The media data could not be decoded. It may be damaged.,
  NSUnderlyingError=0x174247680 "The operation couldn’t be completed. (OSStatus error -12909.)",
  AVErrorMediaTypeKey=vide,
  AVErrorPresentationTimeStampKey=CMTime: {7/30 = 0.233},
  NSLocalizedDescription=Cannot Decode}

AVSampleBufferDisplayLayer 失败之前,我没有收到任何这些错误。

【问题讨论】:

  • 您找到解决方案了吗?为什么它从后台来后停止解码?我有同样的问题。每次将应用程序置于前台时,我都必须创建一个新的AVSampleBufferDisplayLayer 。但这给了我几秒钟的黑屏,这是不行的。
  • 我从来没有找到解决方案。更糟糕的是,我开始从AVSampleBufferDisplayLayer 的内部崩溃,看起来它似乎过度释放了一些内部对象。我已经完全停止使用AVSampleBufferDisplayLayer。目前正在尝试弄清楚如何直接使用VTDecompressionSession的输出。
  • 哦,那是个坏消息。我在 Apple Support 上提交了一张票。如果有有用的东西回来,我会及时通知你。
  • 同样的错误发生,当我们在模拟器上运行项目时,NSLocalizedFailureReason=找不到此媒体所需的编码器。,NSLocalizedDescription=无法编码,AVErrorMediaTypeKey=vide},{ AVErrorMediaSubTypeKey = (1785750887); AVErrorMediaTypeKey = 视频; NSLocalizedDescription = "无法编码"; NSLocalizedFailureReason = "找不到该媒体所需的编码器。"; }.
  • 我没有尝试再次使用AVSampleBufferDisplayLayer。我们使用VTDecompressionSession 并渲染成GLKView 取得了成功。

标签: ios h.264 video-toolbox


【解决方案1】:

重建新的 AVSampleBufferDisplayLayer 后,应将其与最后一个最近的 IDR 帧排入队列,但当前帧是 IDR,这意味着,解码时应将 nalus 保存在一个 GOP 中,并在下一个 IDR 到来时将其删除。

【讨论】:

    【解决方案2】:

    我解决了

    // create renderer
    let renderingLayer = AVSampleBufferDisplayLayer()
    
    // when enqueue data
    if renderingLayer.status == .failed {
        // this way
        renderingLayer.flushAndRemoveImage()
    }
    

    【讨论】:

      【解决方案3】:

      我遇到了同样的问题,并且能够使用以下代码解决。我需要使用 pubDidBecomeActive 事件而不是 willEnterForeground 事件来处理 Siri 被激活的情况。

      class RoomState: NSObject, ObservableObject  {
          private var subs = [AnyCancellable]()
          @Published var displayLayer = AVSampleBufferDisplayLayer()
      
          override init() {
              super.init()
              let pubDidBecomeActive = NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)
              subs.append(pubDidBecomeActive.sink { [weak self] _ in
                  self?.displayLayer = AVSampleBufferDisplayLayer()
              })
          }
      }
      
      

      【讨论】:

        猜你喜欢
        • 2012-04-06
        • 2021-03-31
        • 2012-09-08
        • 2013-09-24
        • 2011-07-23
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-02-17
        相关资源
        最近更新 更多