From 106167374c7e14c6e2afb0049897f1a59a25c839 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 25 May 2023 08:50:19 +0200 Subject: [PATCH] fftools/ffmpeg_mux: flush bsfs immediately on exceeding recoding time Current code marks the output stream as finished and waits for a flush packet, but that is both unnecessary and suspect, as in theory nothing should be sent to a finished stream - not even flush packets. --- fftools/ffmpeg_mux.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 3da3c04d7f..feb014ca31 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -386,6 +386,11 @@ void of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) AVPacket *opkt = ost->pkt; av_packet_unref(opkt); + + if (of->recording_time != INT64_MAX && + dts >= of->recording_time + start_time) + pkt = NULL; + // EOF: flush output bitstream filters. if (!pkt) { of_output_packet(of, opkt, ost, 1); @@ -407,12 +412,6 @@ void of_streamcopy(OutputStream *ost, const AVPacket *pkt, int64_t dts) return; } - if (of->recording_time != INT64_MAX && - dts >= of->recording_time + start_time) { - close_output_stream(ost); - return; - } - if (av_packet_ref(opkt, pkt) < 0) exit_program(1);