From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 011B548794 for ; Sun, 17 Dec 2023 17:36:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A431068D153; Sun, 17 Dec 2023 19:36:49 +0200 (EET) Received: from mail.nihil.gay (nihil.gay [157.90.242.5]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1A5D568CC39 for ; Sun, 17 Dec 2023 19:36:44 +0200 (EET) Received: by mail.nihil.gay (Postfix, from userid 114) id DB0C79D3ED; Sun, 17 Dec 2023 17:36:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on debian-4gb-fsn1-1 X-Spam-Status: No; tests=ALL_TRUSTED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED X-Spam-Score: -1.1 X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily * valid * -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's * domain * -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature * 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. * See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block * for more information. * [URI: nihil.gay] * -0.0 T_SCC_BODY_TEXT_LINE No description available. Received: from localhost.localdomain (host-82-52-80-11.retail.telecomitalia.it [82.52.80.11]) (Authenticated sender: lena@nihil.gay) by mail.nihil.gay (Postfix) with ESMTPSA id 6BD5C9D34A; Sun, 17 Dec 2023 17:36:42 +0000 (UTC) To: ffmpeg-devel@ffmpeg.org Date: Sun, 17 Dec 2023 18:29:33 +0100 Message-ID: <20231217172932.60614-2-lena@nihil.gay> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v4] gdigrab: Allow capturing a window by its handle X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Lena via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Lena , Stefano Sabatini , Remi Denis-Courmont Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 --- 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=\" to specify your target.\n"); + "Please use \"desktop\", \"title=\" or \"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".