From patchwork Sun Nov 19 11:49:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 44717 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6a89:b0:181:818d:5e7f with SMTP id bi9csp993308pzb; Sun, 19 Nov 2023 03:49:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IECQ4AixKIAon3eXLNLf7IbesPd3bradeadGwMbJfw8AjPs0lF+WesL4yvDao9jdzQVZNy0 X-Received: by 2002:a17:906:1707:b0:9e3:f97b:239e with SMTP id c7-20020a170906170700b009e3f97b239emr3753223eje.29.1700394584140; Sun, 19 Nov 2023 03:49:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700394584; cv=none; d=google.com; s=arc-20160816; b=PNLfkdin1DfJ2+6zpZue+8aMMeqn0FnOCszn+MEgri5xh78PosZIdcncuK4BWNXLPo hXO+FOiAhckPuMxqKVF4eErKYyCXuMWOgK5y3gYrbX6E/Tdp4sSwZuPs0xuYsojBJOdW g/8sIenwlqaef7dQukkICY+r2cr+T3awqD3EohKwyeXFbZceKvFCnKPxcy2a8yGU4S1n AzbJ/MSqUN1sFHJBq01tcXknxidp2s+kkqYJpwadGk92nBOP3EBjFI3jkmg3/0hVyCrH xWUlmDtryFLHO2kALdwZPBsdnZmtgXAgo3eIFXeDkQlwvh84pO9X7dirAkeo6e1386hP GxQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=qyr13bghMI326Jk04hqgy8hyLgNHDiPVce00rub0NEc=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=0jxjN3tkpnxGUiCDgiBpLfrkKySTxj3EHUTD3Jbtlma1u79E6gqppA+GF4DLXpllTw D8jCmSF7nJs5C/6aI0wLLpLXrnMWmWdJejEJewf9EE1GH/lcquBC86gHWnD4m4lVWrE1 IZxmgdwHdabtkbddc7hKEjinDrOVtB1rzY7LSJmuJKePB7hN05gGB6ZIxMucGRRnQrQ3 0XEbmaQ2Cyf6oXB/YSxqPBD/PXUT2Tmw8G+UqLNXXCIyVJ5oVnXrxJ6OOaMUGhZZCAAa l/Jc0iJnipDWaFhKlu+R2bwkAXwwxMncQ4GQxweyhH2q2oC0kztkk1XLj6UAAGq3K3fM xpfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h23-20020a170906585700b0097394940619si3303487ejs.984.2023.11.19.03.49.43; Sun, 19 Nov 2023 03:49:44 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C799668CC0B; Sun, 19 Nov 2023 13:49:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E909168CB93 for ; Sun, 19 Nov 2023 13:49:34 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2F59914CE for ; Sun, 19 Nov 2023 12:49:34 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id hxbxSX95zMQC for ; Sun, 19 Nov 2023 12:49:33 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 6401910FE for ; Sun, 19 Nov 2023 12:49:33 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1F9803A0549 for ; Sun, 19 Nov 2023 12:49:27 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Nov 2023 12:49:16 +0100 Message-ID: <20231119114917.1277-1-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/2] doc/filters:ddagrab: elaborate on the semantics of framerate 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: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VkXFyy52Xyj2 --- doc/filters.texi | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/filters.texi b/doc/filters.texi index 38615e4f18..bd4e4ca8f7 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -28163,7 +28163,12 @@ Only affects hardware cursors. If a game or application renders its own cursor, it'll always be captured. @item framerate -Framerate at which the desktop will be captured. +Maximum framerate at which the desktop will be captured - the interval between +successive frames will not be smaller than the inverse of the framerate. When +the desktop is not being updated often enough, the filter will duplicate +a previous frame. Note that there is no background buffering going on, so when +the filter is not polled often enough then the actual inter-frame interval may +be significantly larger. Defaults to 30 FPS. From patchwork Sun Nov 19 11:49:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 44718 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:6a89:b0:181:818d:5e7f with SMTP id bi9csp993362pzb; Sun, 19 Nov 2023 03:49:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IGBUgU0K9OEh/4uDswTCQ6Q/CWlS45VJrX4h4V3acybVwsLtykTxta2RgeSHlHUQCBS0A1V X-Received: by 2002:a17:907:c004:b0:9dd:bd42:4ec7 with SMTP id ss4-20020a170907c00400b009ddbd424ec7mr3541506ejc.38.1700394591998; Sun, 19 Nov 2023 03:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700394591; cv=none; d=google.com; s=arc-20160816; b=huQC4cn84US7nt5J8n1MjPMnSwhonkjp8tB6gbrFVYKLnEk0viCj93f+lf64b9VDpU REDMzhLsuO9LyoX+BnPBV8+MmgGUF2jX/ZMPdX6NqJscGpFj5GYH+9/AXxYeOPyu/+J+ nXUYJYJu1M0LusmVmJA/sydfrGRdoVwGWicR7eSBoQ0p34oBvAnEV63gX4TNO6umWk62 sUaXCdMGD+R5sHMSKWgNAh9J+lTkpO+k7tXKRVL2+9wsy5mEGoGOHXeHiYhxxEr3o5Dy mXVNIe7MIjIUU8eVT5RtDq8ouiu104sGTSDpyQ4WhoMCZOfSGpRNcG+0Creb2xkipDne a4lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:delivered-to; bh=6zLQBdUNSBIOaatO0SJjNU8BDpuqbpK4DLlrLAERjQQ=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=W3ZUyYbvQZYvkPWR89S0EK8B1kjPaPj4WFQRXrrChL4vdAZwwOkrHZDxdmcbLk7VjN k/DCHq7sa3kYrhEJuW3KOAvTbXAjhcrul93ac6buSwoZ3o5mHmF2X/NZ8jhxTsBaGFZS Gmywe4Geu9NTgssLzHKAcm85txaieqAvOvha71Qw3tud6YtTPjE7wqMUsSSFq846W8dH VWv1kAw4tgO9tZJYCmLyr/yn0fepmVlGyF0Sm+zZ/HVinQacxlOZiSVwbHbV4I/MOQrv TW84jMI69WQSLwYQtOn/2hTxIj27FmQcrXzCHJwWZORJzcnRrTHW6edPsFyCKQxdixg3 Z5EA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gx24-20020a170906f1d800b009b2d4dd4a10si3524226ejb.892.2023.11.19.03.49.51; Sun, 19 Nov 2023 03:49:51 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id DB77468CD69; Sun, 19 Nov 2023 13:49:42 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ED17068CC0B for ; Sun, 19 Nov 2023 13:49:34 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 17C5514E4 for ; Sun, 19 Nov 2023 12:49:34 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id BTKL5-3F5Xjp for ; Sun, 19 Nov 2023 12:49:33 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 612C110B9 for ; Sun, 19 Nov 2023 12:49:33 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2D0863A054A for ; Sun, 19 Nov 2023 12:49:27 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sun, 19 Nov 2023 12:49:17 +0100 Message-ID: <20231119114917.1277-2-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231119114917.1277-1-anton@khirnov.net> References: <20231119114917.1277-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/vsrc_ddagrab: add an option to avoid duplicating frames 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: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: WbUDmd+aOS25 --- doc/filters.texi | 15 +++++++++++---- libavfilter/vsrc_ddagrab.c | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index bd4e4ca8f7..30b7c73826 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -28165,10 +28165,10 @@ it'll always be captured. @item framerate Maximum framerate at which the desktop will be captured - the interval between successive frames will not be smaller than the inverse of the framerate. When -the desktop is not being updated often enough, the filter will duplicate -a previous frame. Note that there is no background buffering going on, so when -the filter is not polled often enough then the actual inter-frame interval may -be significantly larger. +@var{dup_frames} is true (the default) and the desktop is not being updated +often enough, the filter will duplicate a previous frame. Note that there is no +background buffering going on, so when the filter is not polled often enough +then the actual inter-frame interval may be significantly larger. Defaults to 30 FPS. @@ -28201,6 +28201,13 @@ Passes all supported output formats to DDA and returns what DDA decides to use. Filter initialization will fail if 10 bit format is requested but unavailable. @end table +@item dup_frames +When this option is set to true (the default), the filter will duplicate frames +when the desktop has not been updated in order to maintain approximately +constant target framerate. When this option is set to false, the filter will +wait for the desktop to be updated (inter-frame intervals may vary significantly +in this case). + @end table @subsection Examples diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c index 9c59faf53e..76dd11af51 100644 --- a/libavfilter/vsrc_ddagrab.c +++ b/libavfilter/vsrc_ddagrab.c @@ -101,6 +101,7 @@ typedef struct DdagrabContext { int out_fmt; int allow_fallback; int force_fmt; + int dup_frames; } DdagrabContext; #define OFFSET(x) offsetof(DdagrabContext, x) @@ -124,6 +125,8 @@ static const AVOption ddagrab_options[] = { OFFSET(allow_fallback), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, { "force_fmt", "exclude BGRA from format list (experimental, discouraged by Microsoft)", OFFSET(force_fmt), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS }, + { "dup_frames", "duplicate frames to maintain framerate", + OFFSET(dup_frames), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS }, { NULL } }; @@ -1067,7 +1070,9 @@ static int ddagrab_request_frame(AVFilterLink *outlink) now -= dda->first_pts; if (!dda->probed_texture) { - ret = next_frame_internal(avctx, &cur_texture, 0); + do { + ret = next_frame_internal(avctx, &cur_texture, 0); + } while (ret == AVERROR(EAGAIN) && !dda->dup_frames); } else { cur_texture = dda->probed_texture; dda->probed_texture = NULL;