From patchwork Mon Jan 29 19:03:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 45890 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:8786:b0:199:de12:6fa6 with SMTP id ph6csp1724836pzb; Mon, 29 Jan 2024 11:03:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRYqqxLcxKmcrk0I2BSuICoIVmPuSivmOew26bbvzwstWDl5dG0YYQKAWtU5y56gmUBlZN X-Received: by 2002:aa7:c419:0:b0:55f:d7a:c7c2 with SMTP id j25-20020aa7c419000000b0055f0d7ac7c2mr1812779edq.16.1706555026231; Mon, 29 Jan 2024 11:03:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1706555026; cv=none; d=google.com; s=arc-20160816; b=1DYUe2O+oxwLPJiWYV/dxzW2FCjO+V/BbpBIdnWGZqQCi9FxntQ4U3zHN1RBk30TvG +ZuN//k91LDMpZEqE6ofN2MvzA63laD+XGiasoxnfgkAcW06OCnEdlIpge7UkKj8JzBp NkWe+MTWYGN4C/E+2hgOSf4LrJlSqTs0115BP8eo3GrJ6mQVNqIZD2Vf01jIvkNW3XQL Q8i/pe+2v9KeBHzmHsp6y/BhSlNfa3Q4t/MgaRjHdWbP3ULSCh2f5vx7LNNBEtYiBfqX lIXGsMDMQsE488gu95ZdG7cniS5bLb4zLeyVtPq1ghTuhWzPl+UEeenH3cK6wni0lOzG 83gg== 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:dkim-signature:delivered-to; bh=5rE0iYeOT1jWckwJxSej+DV/Tc9ClRYBnRaJLq4+Kpo=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=dsu19AkNvjhkZj5zaMMexoX2Jb/IGDzHnXa2HIvJTsh/1KhmcD25TIVwQ7lRg22i3l V/BakLawYbBQ+sam+dz5OeLDLdXB80zqxuRnSwfepf3CISATWXUeEqSltBVtuPQIgof1 Rxrpj0sVzEq9dYpY4X5juSPXiNoX+rypyM4lTpCPqD8JQrjvMGKd4+eNJ138LkpJKhU+ kedUf9S0b2P+RVmG6UZ1LdV0AHCH/2uuHaXfdXmCYqocotYgQ17MrgDmYamjQPVsOjmD xJlvdCFWzUpUSVa2j8G1GDA6yCO8kyYmdxEAKpuKkdZKDGn9uV+3nlXYkdRrGD43p91M yJZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=jR0rO3BB; 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 p13-20020a05640243cd00b0055eea57a8a8si1686995edc.18.2024.01.29.11.03.39; Mon, 29 Jan 2024 11:03:46 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=jR0rO3BB; 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 8CE5B68D255; Mon, 29 Jan 2024 21:03:37 +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 B0F7568D22F for ; Mon, 29 Jan 2024 21:03:31 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=jR0rO3BB; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 43FC119DB for ; Mon, 29 Jan 2024 20:03:31 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id qDGVElYwo2Mk for ; Mon, 29 Jan 2024 20:03:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1706555010; bh=kP8XJt3vuFJ9vDLi7GqBYXDV/YxNrbqpnmQyd8dgd/g=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jR0rO3BBBQ6s/Q42iCEahKZqAtrEToXQx1OG/anfL6LKxeq41qkEJo9t1iNyw49nT 0sR7q5EhJ9sBxVaj57aYjZSg9ISLBN++ER66YoQLRz4VxBt4Mh6eSbAr5qEuQL1mzr Cx2TNZrqAD8rQuuMctW2H4eaB9bG1HBycHx3j4DcZ2yuaj3yoqgmME6MpiyM6ue1Eq zHQp5WT/2H9f9MlApmNqB2eweTMXY+TD7/VjxY34sGJS0mCGghuXhz0f4uBL7/yCtW cvcdQRy1ib3tJ8Pexkr4VFK1ER1EmQFiv/Ajst4vI+iEqPnerTlKskJov79lCLHqno 032vwq8LDeXyA== 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 90F0BEEB for ; Mon, 29 Jan 2024 20:03:30 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6C8893A02A0 for ; Mon, 29 Jan 2024 20:03:30 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 29 Jan 2024 20:03:16 +0100 Message-ID: <20240129190316.17750-1-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <75e6f692-19bd-4b7d-9f7a-1030a5f3f83c@rothenpieler.org> References: <75e6f692-19bd-4b7d-9f7a-1030a5f3f83c@rothenpieler.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] 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: zjaREMGIYrfy Tested-by: Jiří Eliášek, Misha Aizatulin --- 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 1d70f4d934..b9b539acee 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -28713,10 +28713,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. @@ -28749,6 +28749,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..51e928d785 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;