]> git.sesse.net Git - nageru/commitdiff
Properly flush the codecs when rewinding.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Jul 2017 21:53:18 +0000 (23:53 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 12 Jul 2017 21:53:18 +0000 (23:53 +0200)
ffmpeg_capture.cpp

index 1a6703eb5c8d36d19984608fca7212254e35ba93..9a151b60d044c9eb038cdcc7a8c74b5a98e7bbd5 100644 (file)
@@ -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