[FFmpeg-devel] [PATCH] avdevice/gdigrab: Allow capturing a window by its handle

Lena me at lena.place
Thu Nov 3 12:56:37 EET 2022


Signed-off-by: Lena <me at lena.place>
---
 libavdevice/gdigrab.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index c069232472..05d3c0c929 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -273,9 +273,13 @@ gdigrab_read_header(AVFormatContext *s1)
         }
     } else if (!strcmp(filename, "desktop")) {
         hwnd = NULL;
+    } else if (!strncmp(filename, "hwnd=", 5)) {
+        name = filename + 5;
+        
+        hwnd = strtol(name, NULL, 0);
     } else {
         av_log(s1, AV_LOG_ERROR,
-               "Please use \"desktop\" or \"title=<windowname>\" to
specify your target.\n");
+               "Please use \"desktop\", \"title=<windowname>\" or
\"hwnd=<hwnd>\" to specify your target.\n"); ret = AVERROR(EIO);
         goto error;
     }
-- 
2.37.3



More information about the ffmpeg-devel mailing list