From: Steinar H. Gunderson Date: Wed, 12 Jul 2017 21:53:18 +0000 (+0200) Subject: Properly flush the codecs when rewinding. X-Git-Tag: 1.6.2~2 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=804bfa72263942d9beebe749ef0c8dc07a811413 Properly flush the codecs when rewinding. --- diff --git a/ffmpeg_capture.cpp b/ffmpeg_capture.cpp index 1a6703e..9a151b6 100644 --- a/ffmpeg_capture.cpp +++ b/ffmpeg_capture.cpp @@ -425,6 +425,12 @@ bool FFmpegCapture::play_video(const string &pathname) fprintf(stderr, "%s: Rewind failed, not looping.\n", pathname.c_str()); return true; } + if (video_codec_ctx != nullptr) { + avcodec_flush_buffers(video_codec_ctx.get()); + } + if (audio_codec_ctx != nullptr) { + avcodec_flush_buffers(audio_codec_ctx.get()); + } // If the file has changed since last time, return to get it reloaded. // Note that depending on how you move the file into place, you might // end up corrupting the one you're already playing, so this path