From eebfc089d6e55c555f09c39ec0b2bd44a3e32b67 Mon Sep 17 00:00:00 2001 From: itsmattkc <34096995+itsmattkc@users.noreply.github.com> Date: Mon, 18 Jul 2022 20:27:48 -0700 Subject: [PATCH] app: improve video seeking --- app/viewer/mediapanel.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/viewer/mediapanel.cpp b/app/viewer/mediapanel.cpp index 0d90cc8..b004db0 100644 --- a/app/viewer/mediapanel.cpp +++ b/app/viewer/mediapanel.cpp @@ -502,7 +502,7 @@ void MediaPanel::TimerUpdate() { float now = float(QDateTime::currentMSecsSinceEpoch() - m_PlaybackStart) * 0.001f; if (m_VideoStream) { - VideoUpdate(now); + VideoUpdate(now + m_PlaybackOffset); if (!m_SliderPressed && m_SwsFrame->pts != AV_NOPTS_VALUE) { float percent = float(m_SwsFrame->pts) / float(m_VideoStream->duration); @@ -524,7 +524,10 @@ void MediaPanel::SliderPressed() void MediaPanel::SliderMoved(int i) { if (m_VideoStream) { - VideoUpdate(SliderValueToFloatSeconds(i, m_PlayheadSlider->maximum(), m_VideoStream)); + float f = SliderValueToFloatSeconds(i, m_PlayheadSlider->maximum(), m_VideoStream); + m_PlaybackOffset = f; + m_PlaybackStart = QDateTime::currentMSecsSinceEpoch(); + VideoUpdate(f); } if (m_AudioStream) { AudioSeek(SliderValueToFloatSeconds(i, m_PlayheadSlider->maximum(), m_AudioStream));