From: Andriy Gelman <andriy.gel...@gmail.com> When flushing an encoder we send a NULL frame to avcodec_send_frame() and then deque all compressed packets in avcodec_recieve_packet() until AVERROR(EAGAIN) is returned (indicating that all compressed packets have been removed). The second time that avcodec_send_frame() is called with a NULL frame it returns AVERROR_EOF.
At the moment, avcoded_send_frame() treats all errors as fatal errors, even when AVERROR_EOF is returned, meaning that an encoder is not properly shutdown. Since all other returns are handled after the while loop, it suffices to break when AVERROR_EOF is encountered to fix this problem. --- fftools/ffmpeg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 8e408c808a..9e9fc7a714 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1933,12 +1933,8 @@ static void flush_encoders(void) while ((ret = avcodec_receive_packet(enc, &pkt)) == AVERROR(EAGAIN)) { ret = avcodec_send_frame(enc, NULL); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, "%s encoding failed: %s\n", - desc, - av_err2str(ret)); - exit_program(1); - } + if (ret == AVERROR_EOF) + break; } update_benchmark("flush_%s %d.%d", desc, ost->file_index, ost->index); -- 2.23.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".