ffmpeg/fftools
Niklas Haas 38a5fcc02c fftools/ffmpeg_filter: close all no-longer needed inputs
Currently, the thread loop of ffmpeg_filter essentially works like this:

while (1) {
    frame, idx = get_from_decoder();
    err = send_to_filter_graph(frame);
    if (err) { // i.e. EOF
        close_input(idx);
        continue;
    }

    while (filtered_frame = get_filtered_frame())
        send_to_encoder(filtered_frame);
}

The exact details are not 100% correct since the actual control flow is a bit
more complicated as a result of the scheduler, but this is the general flow.

Notably, this leaves the possibility of leaving a no-longer-needed input
permanently open if the filter graph starts producing infinite frames (during
the second loop) *after* it finishes reading from an input, e.g. in a filter
graph like -af atrim,apad.

This patch avoids this issue by always querying the status of all filter graph
inputs and explicitly closing any that were closed downstream; after each round
of reading output frames. As a result, information about the filtergraph being
closed can now propagate back upstream, even if the filter is no longer
requesting any input frames (i.e. input_idx == fg->nb_inputs).

Fixes: https://trac.ffmpeg.org/ticket/11061
See-Also: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20457#issuecomment-6208
2025-11-26 13:15:16 +00:00
..
graph fftools/textformat: renamings in print_unit_int for consistency (cosmetic) 2025-06-27 00:24:35 +02:00
resources fftools/resources: Update .gitignore 2025-08-13 17:39:49 +00:00
textformat fftools/tf_mermaid: close subgraph header when there are no inputs. 2025-11-24 20:01:40 +00:00
cmdutils.c ffplay: print new metadata 2025-11-22 18:38:40 +00:00
cmdutils.h ffplay: print new metadata 2025-11-22 18:38:40 +00:00
ffmpeg.c fftools: Fix MediaCodec on Android15+ 2025-11-23 12:53:43 +00:00
ffmpeg.h fftools/ffmpeg: make fg_create{_simple,} clear the input string pointer 2025-11-01 12:41:23 -03:00
ffmpeg_dec.c ffmpeg: unbreak max_error_rate application 2025-10-21 13:22:08 +00:00
ffmpeg_demux.c fftools/ffmpeg_demux: fix memory leak when creating tile grid filtergraphs 2025-11-01 12:41:23 -03:00
ffmpeg_enc.c fftools: pass global side data through using a separate array 2025-10-30 11:02:01 -03:00
ffmpeg_filter.c fftools/ffmpeg_filter: close all no-longer needed inputs 2025-11-26 13:15:16 +00:00
ffmpeg_hw.c avutil/common: Don't auto-include mem.h 2024-03-31 00:08:43 +01:00
ffmpeg_mux.c fftools/ffmpeg_mux: move OutputStream.enc_ctx to Encoder 2024-09-30 09:29:18 +02:00
ffmpeg_mux.h fftools/ffmpeg_mux: Make ms_from_ost() inline 2025-05-15 23:08:05 +02:00
ffmpeg_mux_init.c fftools/ffmpeg: make fg_create{_simple,} clear the input string pointer 2025-11-01 12:41:23 -03:00
ffmpeg_opt.c fftools/ffmpeg: make fg_create{_simple,} clear the input string pointer 2025-11-01 12:41:23 -03:00
ffmpeg_sched.c fftools/ffmpeg_sched: prevent demuxers from getting stuck 2025-11-10 09:55:40 +00:00
ffmpeg_sched.h fftools/ffmpeg_sched: add a function to remove a filtergraph from the scheduler 2025-10-30 11:02:01 -03:00
ffmpeg_utils.h fftools/ffmpeg: propagate decoded_side_data from decoded streams to the filterchain 2025-01-25 21:56:49 -03:00
ffplay.c ffplay: print new metadata 2025-11-22 18:38:40 +00:00
ffplay_renderer.c fftools/ffplay_renderer: Use new vulkan queue API 2025-06-20 20:39:15 +08:00
ffplay_renderer.h fftools/ffplay: add hwaccel decoding support 2023-11-15 01:20:11 +08:00
ffprobe.c fftools/ffprobe: add AVFrame.alpha_mode support 2025-09-02 17:06:25 +02:00
fftools.manifest fftools: add DPI awareness manifest 2022-08-13 14:42:52 +02:00
fftoolsres.rc fftools: add DPI awareness manifest 2022-08-13 14:42:52 +02:00
fopen_utf8.h avutil/common: Don't auto-include mem.h 2024-03-31 00:08:43 +01:00
Makefile fftools: Fix MediaCodec on Android15+ 2025-11-23 12:53:43 +00:00
opt_common.c ALL: move av_unused to conform with standard requirement 2025-09-26 16:15:46 +00:00
opt_common.h fftools/opt_common: add long-form license option 2025-10-12 03:26:21 +00:00
sync_queue.c fftools/sync_queue: switch from AVFifo+ObjPool to AVContainerFifo 2024-12-15 14:05:34 +01:00
sync_queue.h fftools/sync_queue: add debug logging 2023-05-28 10:47:59 +02:00
thread_queue.c fftools/thread_queue: allow choking thread queues directly 2025-09-30 13:16:59 +02:00
thread_queue.h fftools/thread_queue: allow choking thread queues directly 2025-09-30 13:16:59 +02:00