From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] lavfi/vsrc_ddagrab: add an option to avoid duplicating frames
Date: Sun, 19 Nov 2023 12:49:17 +0100
Message-ID: <20231119114917.1277-2-anton@khirnov.net> (raw)
In-Reply-To: <20231119114917.1277-1-anton@khirnov.net>
---
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;
--
2.42.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".
next prev parent reply other threads:[~2023-11-19 11:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-19 11:49 [FFmpeg-devel] [PATCH 1/2] doc/filters:ddagrab: elaborate on the semantics of framerate Anton Khirnov
2023-11-19 11:49 ` Anton Khirnov [this message]
2023-11-22 4:02 ` Gyan Doshi
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=20231119114917.1277-2-anton@khirnov.net \
--to=anton@khirnov.net \
--cc=ffmpeg-devel@ffmpeg.org \
/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