diff --git a/src/Qt/PlayerPrivate.cpp b/src/Qt/PlayerPrivate.cpp index 865868b0..ef0e11c7 100644 --- a/src/Qt/PlayerPrivate.cpp +++ b/src/Qt/PlayerPrivate.cpp @@ -71,9 +71,6 @@ namespace openshot const auto frame_duration = double_micro_sec(1000000.0 / reader->info.fps.ToDouble()); const auto max_sleep = frame_duration * 4; ///< Don't sleep longer than X times a frame duration - // Get the current video frame - frame = getFrame(); - // Pausing Code (if frame has not changed) // Also pause at end of timeline, and pause if 'playing' and // the pre-roll is not yet ready @@ -92,6 +89,9 @@ namespace openshot continue; } + // Get the current video frame + frame = getFrame(); + // Set the video frame on the video thread and render frame videoPlayback->frame = frame; videoPlayback->render.signal(); diff --git a/src/Qt/VideoCacheThread.cpp b/src/Qt/VideoCacheThread.cpp index b2288866..89f2afbb 100644 --- a/src/Qt/VideoCacheThread.cpp +++ b/src/Qt/VideoCacheThread.cpp @@ -79,6 +79,7 @@ namespace openshot while (!threadShouldExit() && is_playing) { // Calculate on-screen time for a single frame const auto frame_duration = double_micro_sec(1000000.0 / reader->info.fps.ToDouble()); + int current_speed = speed; // Calculate bytes per frame. If we have a reference openshot::Frame, use that instead (the preview // window can be smaller, can thus reduce the bytes per frame) @@ -141,6 +142,10 @@ namespace openshot break; } } + // Check if playback speed changed (if so, break out of cache loop) + if (current_speed != speed) { + break; + } } // Update current display frame