HarmonyOS 视频解码的时候OH\_VideoDecoder\_RenderOutputBuffer方法一直返回为2?

参考官方案例,使用XComponent渲染解码后的视频,但是解码的方法OH\_VideoDecoder\_RenderOutputBuffer一直返回2,导致demo没有画面。

代码:

int32_t VideoDecoder::FreeOutputData(uint32_t bufferIndex, bool render)
{
  if (decoder == nullptr) {
    OH_LOG_ERROR(LOG_APP, "Decoder is null");
    return AV_ERR_UNKNOWN;
  }

  int32_t ret = AV_ERR_OK;
  if (render) {
    ret = OH_VideoDecoder_RenderOutputBuffer(decoder, bufferIndex);
  } else {
    ret = OH_VideoDecoder_FreeOutputBuffer(decoder, bufferIndex);
  }
  if (ret != AV_ERR_OK) {
    OH_LOG_ERROR(LOG_APP, "Free output data failed: ret=%{public}d", ret);
    return AV_ERR_UNKNOWN;
  }
  return AV_ERR_OK;
}
int32_t ret = videoDecoder_->FreeOutputData(bufferInfo.bufferIndex, true);
if (ret != AV_ERR_OK) {
  OH_LOG_ERROR(LOG_APP, "Decoder output thread out");
  break;
}

结果:

07-31 17:36:22.031   55381-55416  C02B30/NativeVideoDecoder      pid-55381             E     {OH_VideoDecoder_RenderOutputBuffer():637} Video decoder render output data failed!
07-31 17:36:22.031   55381-55416  A00000/VideoDecoder            pid-55381             E     Free output data failed: ret=2
07-31 17:36:22.031   55381-55416  A00000/player                  pid-55381             E     Decoder output thread out
阅读 464
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进