1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

ffmpeg.c - drain all decoded frames during stream_loop flush

When a decoded stream is being looped, after each post-EOF rewind,
decoders are flushed in seek_to_start(). This only drains 1 frame, and
thus the output has a few frames missing at the tail of each iteration
except the last.

With this patch, process_input is looped till process_input_packet
reaches EOF.

Fixes #7081

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Gyan Doshi 2018-03-15 16:45:51 +05:30 committed by Michael Niedermayer
parent 2aac5ad2f7
commit 8ad83044b4

View File

@ -4170,12 +4170,6 @@ static int seek_to_start(InputFile *ifile, AVFormatContext *is)
ist = input_streams[ifile->ist_index + i];
avctx = ist->dec_ctx;
// flush decoders
if (ist->decoding_needed) {
process_input_packet(ist, NULL, 1);
avcodec_flush_buffers(avctx);
}
/* duration is the length of the last frame in a stream
* when audio stream is present we don't care about
* last video frame length because it's not defined exactly */
@ -4244,6 +4238,17 @@ static int process_input(int file_index)
return ret;
}
if (ret < 0 && ifile->loop) {
AVCodecContext *avctx;
for (i = 0; i < ifile->nb_streams; i++) {
ist = input_streams[ifile->ist_index + i];
avctx = ist->dec_ctx;
if (ist->decoding_needed) {
ret = process_input_packet(ist, NULL, 1);
if (ret>0)
return 0;
avcodec_flush_buffers(avctx);
}
}
ret = seek_to_start(ifile, is);
if (ret < 0)
av_log(NULL, AV_LOG_WARNING, "Seek to start failed.\n");