From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 446E84E100 for ; Sun, 6 Jul 2025 22:00:56 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id CBC73691315; Mon, 7 Jul 2025 01:00:35 +0300 (EEST) Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 41CA969130E for ; Mon, 7 Jul 2025 01:00:29 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8A066EAFB7; Sun, 6 Jul 2025 23:57:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tcXmNFqwa4Qv; Sun, 6 Jul 2025 23:57:49 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8DB93EB0C5; Sun, 6 Jul 2025 23:57:49 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Jul 2025 00:00:03 +0200 Message-ID: <20250706220011.5799-3-cus@passwd.hu> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250706220011.5799-1-cus@passwd.hu> References: <20250706220011.5799-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/4] fftools/ffmpeg: add support for setting maximum buffered frames in a filtergraph 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 Cc: Marton Balint 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: Signed-off-by: Marton Balint --- 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".