使用 FFMPEG 从 D3D11VA hwdevice 派生 qsv hwdevice

发布于 2025-01-12 05:19:16 字数 1172 浏览 2 评论 0原文

我正在尝试从 D3D11VA 设备派生 QSV hwcontext 以便对 d3d11 帧进行编码,但在调用 av_hwdevice_ctx_create_driven 时出现错误。

  buffer_t ctx_buf { av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_D3D11VA) };

  auto ctx = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)ctx_buf->data)->hwctx;

  std::fill_n((std::uint8_t *)ctx, sizeof(AVD3D11VADeviceContext), 0);

  auto device = (ID3D11Device *)hwdevice_ctx->data;

  device->AddRef();
  ctx->device = device;

  ctx->lock_ctx = (void *)1;
  ctx->lock     = do_nothing;
  ctx->unlock   = do_nothing;

  auto err = av_hwdevice_ctx_init(ctx_buf.get());

然后我打电话

  av_hwdevice_ctx_create_derived(&derive_hw_device_ctx, AV_HWDEVICE_TYPE_QSV, ctx_buf.get(), 0);

我在日志中看到了这一点:

[AVHWDeviceContext @ 000001de119a9b80] Initialize MFX session: API version is 1.35, implementation version is 1.30
[AVHWDeviceContext @ 000001de119a9b80] Error setting child device handle: -16

如果您有任何想法如何修复它或在 QSV 编码器上编码 d3d11 帧的不同方法,请告诉我。

谢谢。

OS: windows 10 64bits
CPU: Intel i5-8400
Graphics card: Nvidia GT1030 (has no hw encoder)

I'm trying to derive a QSV hwcontext from D3D11VA device in order to encode d3d11 frames but I'm getting an error when calling av_hwdevice_ctx_create_derived.

  buffer_t ctx_buf { av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_D3D11VA) };

  auto ctx = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)ctx_buf->data)->hwctx;

  std::fill_n((std::uint8_t *)ctx, sizeof(AVD3D11VADeviceContext), 0);

  auto device = (ID3D11Device *)hwdevice_ctx->data;

  device->AddRef();
  ctx->device = device;

  ctx->lock_ctx = (void *)1;
  ctx->lock     = do_nothing;
  ctx->unlock   = do_nothing;

  auto err = av_hwdevice_ctx_init(ctx_buf.get());

and then I call

  av_hwdevice_ctx_create_derived(&derive_hw_device_ctx, AV_HWDEVICE_TYPE_QSV, ctx_buf.get(), 0);

I'm seeing this in the log:

[AVHWDeviceContext @ 000001de119a9b80] Initialize MFX session: API version is 1.35, implementation version is 1.30
[AVHWDeviceContext @ 000001de119a9b80] Error setting child device handle: -16

Please let me know if you have any idea how to fix it or a different approach to encode d3d11 frames on QSV encoder.

Thank you.

OS: windows 10 64bits
CPU: Intel i5-8400
Graphics card: Nvidia GT1030 (has no hw encoder)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你与昨日 2025-01-19 05:19:16

将其添加到 d3d11 设备解决了该问题:

ID3D10Multithread *pMultithread;

  status = device->QueryInterface(IID_ID3D10Multithread, (void **)&pMultithread);
  if(SUCCEEDED(status)) {
    pMultithread->SetMultithreadProtected(TRUE);
    Release(pMultithread);
  }

Adding this to d3d11 device solved the issue:

ID3D10Multithread *pMultithread;

  status = device->QueryInterface(IID_ID3D10Multithread, (void **)&pMultithread);
  if(SUCCEEDED(status)) {
    pMultithread->SetMultithreadProtected(TRUE);
    Release(pMultithread);
  }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文