From 9566fb7acff01044c57ca1f525895ad64cfc2afe Mon Sep 17 00:00:00 2001 From: jimcamel Date: Tue, 25 Jun 2019 17:09:46 +1200 Subject: [PATCH] Fixed bug where FFmpeg Image Stream would stop if paused for more than 10 seconds The FFmpeg image stream class uses a 10 second timeout between frames to determine if the stream is dead and if so closes it. However, the timeout is determined using the variable lastUpdateTS which stores the last time the publishNewFrame function was called, and if the video has been playing and then is paused for longer than 10 seconds, when it is unpaused this timeout will fire and the stream will be closed, stopping the video playing beyond what has been buffered. To stop this timeout from happening before the video starts playing, the timeout checks to see if the lastUpdateTS > 0 (at initialization it is set to 0). In this fix, we simply set the value of lastUpdateTS to 0 when the video is unpaused, this will force the check to skip on unpause, and from then on lastUpdateTS will have the correct value again. The lastUpdateTS variable is private and only used for this one function, so there should be no side effects from the change. --- src/osgPlugins/ffmpeg/FFmpegImageStream.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp b/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp index 0bfd78905..f06dfada7 100644 --- a/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp +++ b/src/osgPlugins/ffmpeg/FFmpegImageStream.cpp @@ -305,6 +305,8 @@ void FFmpegImageStream::cmdPlay() m_decoder->video_decoder().pause(false); m_decoder->audio_decoder().pause(false); + + _lastUpdateTS = 0.; } _status = PLAYING;