From d0e576aa0c63a260d4a27d57326c0d16fb7997a2 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 9 Mar 2019 22:01:00 +0100 Subject: [PATCH] Fix an issue where Matroska HTTP FFmpeg streams would not correctly restart on connection close. --- nageru/ffmpeg_capture.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nageru/ffmpeg_capture.cpp b/nageru/ffmpeg_capture.cpp index 722d313..9beea85 100644 --- a/nageru/ffmpeg_capture.cpp +++ b/nageru/ffmpeg_capture.cpp @@ -467,6 +467,11 @@ bool FFmpegCapture::play_video(const string &pathname) } if (frame == nullptr) { // EOF. Loop back to the start if we can. + if (format_ctx->pb != nullptr && format_ctx->pb->seekable == 0) { + // Not seekable (but seemingly, sometimes av_seek_frame() would return 0 anyway, + // so don't try). + return true; + } if (av_seek_frame(format_ctx.get(), /*stream_index=*/-1, /*timestamp=*/0, /*flags=*/0) < 0) { fprintf(stderr, "%s: Rewind failed, not looping.\n", pathname.c_str()); return true; -- 2.39.2