Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Lena via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Lena <lena@nihil.gay>, Stefano Sabatini <stefasab@gmail.com>,
	Remi Denis-Courmont <remi@remlab.net>
Subject: [FFmpeg-devel] [PATCH v4] gdigrab: Allow capturing a window by its handle
Date: Sun, 17 Dec 2023 18:29:33 +0100
Message-ID: <20231217172932.60614-2-lena@nihil.gay> (raw)
In-Reply-To: <ZX3C6HwZigEomyqD@mariano>

Added more context in the error message and did a final test that it all works.

Thanks for the smooth patch submission process!


x11grab can capture windows by their ID, but gdigrab can only capture windows by their names, internally calling FindWindowW to lookup its handle.

This patch simply allows the user to specify a window handle directly.
Signed-off-by: Lena <lena@nihil.gay>
---
 doc/indevs.texi       |  8 ++++++--
 libavdevice/gdigrab.c | 15 ++++++++++++++-
 2 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/doc/indevs.texi b/doc/indevs.texi
index 863536a34d..a0c684f545 100644
--- a/doc/indevs.texi
+++ b/doc/indevs.texi
@@ -722,7 +722,7 @@ Win32 GDI-based screen capture device.
 
 This device allows you to capture a region of the display on Windows.
 
-There are two options for the input filename:
+Amongst options for the imput filenames are such elements as:
 @example
 desktop
 @end example
@@ -730,9 +730,13 @@ or
 @example
 title=@var{window_title}
 @end example
+or
+@example
+hwnd=@var{window_hwnd}
+@end example
 
 The first option will capture the entire desktop, or a fixed region of the
-desktop. The second option will instead capture the contents of a single
+desktop. The second and third options will instead capture the contents of a single
 window, regardless of its position on the screen.
 
 For example, to grab the entire desktop using @command{ffmpeg}:
diff --git a/libavdevice/gdigrab.c b/libavdevice/gdigrab.c
index c069232472..aa909a9392 100644
--- a/libavdevice/gdigrab.c
+++ b/libavdevice/gdigrab.c
@@ -273,9 +273,22 @@ gdigrab_read_header(AVFormatContext *s1)
         }
     } else if (!strcmp(filename, "desktop")) {
         hwnd = NULL;
+    } else if (!strncmp(filename, "hwnd=", 5)) {
+        name = filename + 5;
+        char *p;
+
+        hwnd = strtol(name, &p, 0);
+
+        if (p == NULL || p == name || p[0] == '\0')
+        {
+            av_log(s1, AV_LOG_ERROR,
+                   "Invalid window handle '%s', must be an valid integer.\n", name);
+            ret = AVERROR(EINVAL);
+            goto error;
+        }
     } 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.43.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2023-12-17 17:36 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-10 22:10 [FFmpeg-devel] [PATCH] " Lena via ffmpeg-devel
2023-12-11  0:34 ` Andreas Rheinhardt
2023-12-11  1:35   ` Lena via ffmpeg-devel
2023-12-11  1:52   ` Lena via ffmpeg-devel
2023-12-12  0:47     ` Stefano Sabatini
2023-12-12 13:59       ` [FFmpeg-devel] [PATCH v2] " Lena via ffmpeg-devel
2023-12-12 14:07         ` Nicolas George
2023-12-12 15:31           ` Rémi Denis-Courmont
2023-12-13 10:03             ` Nicolas George
2023-12-14 10:32               ` [FFmpeg-devel] [PATCH v3] " Lena via ffmpeg-devel
2023-12-16 15:31                 ` Stefano Sabatini
2023-12-17 17:29                   ` Lena via ffmpeg-devel [this message]
2023-12-17 18:17                     ` [FFmpeg-devel] [PATCH v4] " Stefano Sabatini
2023-12-14 10:52               ` [FFmpeg-devel] [PATCH v2] " Rémi Denis-Courmont

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231217172932.60614-2-lena@nihil.gay \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=lena@nihil.gay \
    --cc=remi@remlab.net \
    --cc=stefasab@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git