From 804bfa72263942d9beebe749ef0c8dc07a811413 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 12 Jul 2017 23:53:18 +0200 Subject: [PATCH] Properly flush the codecs when rewinding. --- ffmpeg_capture.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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 -- 2.39.2