[FFmpeg-cvslog] fftools/ffmpeg_filter: always reap all available frames before requesting new ones
Marton Balint
git at videolan.org
Thu Jul 3 23:07:16 EEST 2025
ffmpeg | branch: master | Marton Balint <cus at passwd.hu> | Fri Jun 20 19:59:11 2025 +0200| [42bcbdd456d1ca2aa2d0665840830f0a5bf8be39] | committer: Marton Balint
fftools/ffmpeg_filter: always reap all available frames before requesting new ones
alfilter_graph_request_oldest() might return EAGAIN and produce a frame on not
the oldest sink.
Fixes ticket #11597.
Fixes excessive frame buffering in #10959.
Fixes excessive frame buffering in #11366.
Signed-off-by: Marton Balint <cus at passwd.hu>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42bcbdd456d1ca2aa2d0665840830f0a5bf8be39
---
fftools/ffmpeg_filter.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index a0dc4c745e..f6e496158c 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -2669,6 +2669,22 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt,
while (fgp->nb_outputs_done < fg->nb_outputs) {
int ret;
+ /* Reap all buffers present in the buffer sinks */
+ for (int i = 0; i < fg->nb_outputs; i++) {
+ OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[i]);
+
+ ret = 0;
+ while (!ret) {
+ ret = fg_output_step(ofp, fgt, frame);
+ if (ret < 0)
+ return ret;
+ }
+ }
+
+ // return after one iteration, so that scheduler can rate-control us
+ if (did_step && fgp->have_sources)
+ return 0;
+
ret = avfilter_graph_request_oldest(fgt->graph);
if (ret == AVERROR(EAGAIN)) {
fgt->next_in = choose_input(fg, fgt);
@@ -2684,21 +2700,6 @@ static int read_frames(FilterGraph *fg, FilterGraphThread *fgt,
}
fgt->next_in = fg->nb_inputs;
- // return after one iteration, so that scheduler can rate-control us
- if (did_step && fgp->have_sources)
- return 0;
-
- /* Reap all buffers present in the buffer sinks */
- for (int i = 0; i < fg->nb_outputs; i++) {
- OutputFilterPriv *ofp = ofp_from_ofilter(fg->outputs[i]);
-
- ret = 0;
- while (!ret) {
- ret = fg_output_step(ofp, fgt, frame);
- if (ret < 0)
- return ret;
- }
- }
did_step = 1;
}
More information about the ffmpeg-cvslog
mailing list