From: Marton Balint <cus@passwd.hu> To: ffmpeg-devel@ffmpeg.org Cc: Marton Balint <cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 3/4] fftools/ffmpeg: add support for setting maximum buffered frames in a filtergraph Date: Mon, 7 Jul 2025 00:00:03 +0200 Message-ID: <20250706220011.5799-3-cus@passwd.hu> (raw) In-Reply-To: <20250706220011.5799-1-cus@passwd.hu> Signed-off-by: Marton Balint <cus@passwd.hu> --- doc/ffmpeg.texi | 9 +++++++++ fftools/ffmpeg.h | 1 + fftools/ffmpeg_filter.c | 6 ++++++ fftools/ffmpeg_opt.c | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi index 35675b5309..6dea7ce7a0 100644 --- a/doc/ffmpeg.texi +++ b/doc/ffmpeg.texi @@ -1384,6 +1384,15 @@ Defines how many threads are used to process a filter pipeline. Each pipeline will produce a thread pool with this many threads available for parallel processing. The default is the number of available CPUs. +@item -filter_buffered_frames @var{nb_frames} (@emph{global}) +Defines the maximum number of buffered frames allowed in a filtergraph. Under +normal circumstances, a filtergraph should not buffer more than a few frames, +especially if frames are being fed to it and read from it in a balanced way +(which is the intended behavior in ffmpeg). That said, this option allows you +to limit the total number of frames buffered across all links in a filtergraph. +If more frames are generated, filtering is aborted and an error is returned. +The default value is 0, which means no limit. + @item -pre[:@var{stream_specifier}] @var{preset_name} (@emph{output,per-stream}) Specify the preset for matching stream(s). diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 7868f3d85f..53f71bc080 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -737,6 +737,7 @@ extern float max_error_rate; extern char *filter_nbthreads; extern int filter_complex_nbthreads; +extern int filter_buffered_frames; extern int vstats_version; extern int print_graphs; extern char *print_graphs_file; diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index f6e496158c..d6f9c610d6 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1949,6 +1949,12 @@ static int configure_filtergraph(FilterGraph *fg, FilterGraphThread *fgt) fgt->graph->nb_threads = filter_complex_nbthreads; } + if (filter_buffered_frames) { + ret = av_opt_set_int(fgt->graph, "max_buffered_frames", filter_buffered_frames, 0); + if (ret < 0) + return ret; + } + hw_device = hw_device_for_filter(); ret = graph_parse(fg, fgt->graph, graph_desc, &inputs, &outputs, hw_device); diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 3d1efe32f9..d714a1523a 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -75,6 +75,7 @@ int stdin_interaction = 1; float max_error_rate = 2.0/3; char *filter_nbthreads; int filter_complex_nbthreads = 0; +int filter_buffered_frames = 0; int vstats_version = 2; int print_graphs = 0; char *print_graphs_file = NULL; @@ -1714,6 +1715,9 @@ const OptionDef options[] = { { "filter_threads", OPT_TYPE_FUNC, OPT_FUNC_ARG | OPT_EXPERT, { .func_arg = opt_filter_threads }, "number of non-complex filter threads" }, + { "filter_buffered_frames", OPT_TYPE_INT, OPT_EXPERT, + { &filter_buffered_frames }, + "maximum number of buffered frames in a filter graph" }, #if FFMPEG_OPT_FILTER_SCRIPT { "filter_script", OPT_TYPE_STRING, OPT_PERSTREAM | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(filter_scripts) }, -- 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".
next prev parent reply other threads:[~2025-07-06 22:00 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2025-07-06 22:00 [FFmpeg-devel] [PATCH 1/4] avfilter/framequeue: add support for limiting and tracking buffered frames in the queues Marton Balint 2025-07-06 22:00 ` [FFmpeg-devel] [PATCH 2/4] avfilter/avfilter: add AVFilterGraph->max_buffered_frames to limit buffered frames Marton Balint 2025-07-06 22:00 ` Marton Balint [this message] 2025-07-06 22:00 ` [FFmpeg-devel] [PATCH 4/4] tests/fate: add fate test for excessive frame buffering when using filters Marton Balint
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=20250706220011.5799-3-cus@passwd.hu \ --to=cus@passwd.hu \ --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