mirror of https://github.com/FFmpeg/FFmpeg.git
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
Backported-from:
|
||
|---|---|---|
| .. | ||
| Makefile | ||
| cmdutils.c | ||
| cmdutils.h | ||
| ffmpeg.c | ||
| ffmpeg.h | ||
| ffmpeg_dec.c | ||
| ffmpeg_demux.c | ||
| ffmpeg_enc.c | ||
| ffmpeg_filter.c | ||
| ffmpeg_hw.c | ||
| ffmpeg_mux.c | ||
| ffmpeg_mux.h | ||
| ffmpeg_mux_init.c | ||
| ffmpeg_opt.c | ||
| ffmpeg_sched.c | ||
| ffmpeg_sched.h | ||
| ffmpeg_utils.h | ||
| ffplay.c | ||
| ffplay_renderer.c | ||
| ffplay_renderer.h | ||
| ffprobe.c | ||
| fftools.manifest | ||
| fftoolsres.rc | ||
| fopen_utf8.h | ||
| objpool.c | ||
| objpool.h | ||
| opt_common.c | ||
| opt_common.h | ||
| sync_queue.c | ||
| sync_queue.h | ||
| thread_queue.c | ||
| thread_queue.h | ||