使用 FFMPEG 从 D3D11VA hwdevice 派生 qsv hwdevice
Derive qsv hwdevice from D3D11VA hwdevice using FFMPEG
我正在尝试从 D3D11VA 设备派生 QSV hwcontext 以便对 d3d11 帧进行编码,但在调用 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());
然后我打电话给
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)
将此添加到 d3d11 设备解决了问题:
ID3D10Multithread *pMultithread;
status = device->QueryInterface(IID_ID3D10Multithread, (void **)&pMultithread);
if(SUCCEEDED(status)) {
pMultithread->SetMultithreadProtected(TRUE);
Release(pMultithread);
}
我正在尝试从 D3D11VA 设备派生 QSV hwcontext 以便对 d3d11 帧进行编码,但在调用 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());
然后我打电话给
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)
将此添加到 d3d11 设备解决了问题:
ID3D10Multithread *pMultithread;
status = device->QueryInterface(IID_ID3D10Multithread, (void **)&pMultithread);
if(SUCCEEDED(status)) {
pMultithread->SetMultithreadProtected(TRUE);
Release(pMultithread);
}