[FFmpeg-devel] [PATCH] Fix failure to initialize ddagrab if adapter ID is specified

Jøger Hansegård joger.hansegard at qt.io
Thu Jun 1 17:18:17 EEST 2023

>From dd7208b1edd0d7efcde1a12fd468a180737ad9cd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= <joger.hansegard at qt.io>
Date: Thu, 1 Jun 2023 15:30:48 +0200
Subject: [PATCH] Fix failure to initialize ddagrab if adapter ID is specified

If an adapter ID is specified when initializing hw device for d3d11va,
ddagrab does not work on Windows 11. This prevents capturing screens
connected to a secondary adapter.

Failing command:
    ffmpeg -init_hw_device d3d11va:0 -filter_complex ddagrab=0,hwdownload,format=bgra -c:v h264_mf output.mkv

The reason is that d3d11va_device_create uses CreateDXGIFactory to
create a DXGIFactory 1.0. This causes init_dxgi_dda's call to
IDXGIOutput5_DuplicateOutput1 to fail because it is only supported on
DXGI 1.1 and higher.

The fix is to always crate DXGI factory using CreateDXGIFactory1 as
proposed in this patch.

Fixes: #10385
 libavutil/hwcontext_d3d11va.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index aa50538d64..fa8d5410f2 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -62,7 +62,7 @@ static av_cold void load_functions(void)

     mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE) GetProcAddress(d3dlib, "D3D11CreateDevice");
-    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory");
+    mCreateDXGIFactory = (PFN_CREATE_DXGI_FACTORY) GetProcAddress(dxgilib, "CreateDXGIFactory1");
     // In UWP (which lacks LoadLibrary), CreateDXGIFactory isn't available,
     // only CreateDXGIFactory1

More information about the ffmpeg-devel mailing list