diff options
author | James Almer <jamrial@gmail.com> | 2022-02-14 14:07:01 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-02-28 12:10:51 -0300 |
commit | afe485ee6b3bbcd4b0e106eb9fc4dcf4846db1b8 (patch) | |
tree | 32cd46c17fc1afe94dac7f6d5576e3f27468bb75 /fftools/ffmpeg.c | |
parent | 4f21a9ae6b86cc481af4f92249bef877bdf64fdc (diff) |
ffmpeg: flush delayed frames in codec copy scenarios
Bitstream filters inserted between the input and output were never drained,
resulting in packets being lost if the bsf had any buffered.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'fftools/ffmpeg.c')
-rw-r--r-- | fftools/ffmpeg.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 7beea11933..66e5ec8c8e 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2001,7 +2001,7 @@ static int check_output_constraints(InputStream *ist, OutputStream *ost) if (ost->source_index != ist_index) return 0; - if (ost->finished) + if (ost->finished & MUXER_FINISHED) return 0; if (of->start_time != AV_NOPTS_VALUE && ist->pts < of->start_time) @@ -2733,7 +2733,9 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo } ist->pts = ist->dts; ist->next_pts = ist->next_dts; - } + } else if (!ist->decoding_needed) + eof_reached = 1; + for (i = 0; i < nb_output_streams; i++) { OutputStream *ost = output_streams[i]; @@ -4213,11 +4215,12 @@ static int process_input(int file_index) for (i = 0; i < ifile->nb_streams; i++) { ist = input_streams[ifile->ist_index + i]; avctx = ist->dec_ctx; - if (ist->decoding_needed) { + if (ist->processing_needed) { ret = process_input_packet(ist, NULL, 1); if (ret>0) return 0; - avcodec_flush_buffers(avctx); + if (ist->decoding_needed) + avcodec_flush_buffers(avctx); } } #if HAVE_THREADS @@ -4247,7 +4250,7 @@ static int process_input(int file_index) for (i = 0; i < ifile->nb_streams; i++) { ist = input_streams[ifile->ist_index + i]; - if (ist->decoding_needed) { + if (ist->processing_needed) { ret = process_input_packet(ist, NULL, 0); if (ret>0) return 0; |