[PATCH] Fix jerky and inaccurate clip monitor ruler and playback

Mikko Rapeli mikko.rapeli at iki.fi
Thu Jan 19 23:41:18 UTC 2017


Kdenlive used to have frame accurate preview on my slow i686 Thinkpad
laptop, not in real-time but close enough in HD resolutions.
Changes to buffering, asynchronous processing and frame dropping
screwed my time line accurace in clip and timeline previews.

For example, zone playbacks were stopping 25 frames before end of zone
and quickly seeking to the last frame. Sometimes timeline ruler was
left off. Then stopping playback included always a 5 frame jump to the
future. These map to the buffer size and drop_max properties of
https://www.mltframework.org/doxygen/structmlt__consumer__s.html

With these tunings set, I get a pretty and accurate timeline again.
Especially when using proxy clips which my PC can play in real time.

Well, almost. Stopping clip playback with space or mouse clicks jumps the
time line cursor a few frames to the future. Luckily setting
zone in and out points works fine. Maybe there is some similar fix required
somewhere else?

I thikn on faster modern machines users don't see problems like these,
except under heavy load, but to me these setting seem good defaults.
Accuracy is more important to me than real-time playback when working
with a video timeline.

Signed-off-by: Mikko Rapeli <mikko.rapeli at iki.fi>
---
 src/monitor/glwidget.cpp |  4 +++-
 src/renderer.cpp         | 18 ++++++------------
 2 files changed, 9 insertions(+), 13 deletions(-)

diff --git a/src/monitor/glwidget.cpp b/src/monitor/glwidget.cpp
index b6a5117..becd94b 100644
--- a/src/monitor/glwidget.cpp
+++ b/src/monitor/glwidget.cpp
@@ -993,7 +993,7 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
             if (!KdenliveSettings::monitor_dropframes()) {
                 dropFrames = -dropFrames;
             }
-            m_consumer->set("real_time", dropFrames);
+            m_consumer->set("real_time", 0);
             m_threadCreateEvent = m_consumer->listen("consumer-thread-create", this, (mlt_listener) onThreadCreate);
             m_threadJoinEvent = m_consumer->listen("consumer-thread-join", this, (mlt_listener) onThreadJoin);
         }
@@ -1049,6 +1049,8 @@ int GLWidget::reconfigure(Mlt::Profile *profile)
         m_consumer->set("deinterlace_method", KdenliveSettings::mltdeinterlacer().toUtf8().constData());
         m_consumer->set("buffer", 25);
         m_consumer->set("prefill", 1);
+        m_consumer->set("real_time", 0);
+        m_consumer->set("drop_max", 0);
         m_consumer->set("scrub_audio", 1);
         if (KdenliveSettings::monitor_gamma() == 0) {
             m_consumer->set("color_trc", "iec61966_2_1");
diff --git a/src/renderer.cpp b/src/renderer.cpp
index ceb40b8..4306074 100644
--- a/src/renderer.cpp
+++ b/src/renderer.cpp
@@ -736,13 +736,10 @@ void Render::switchPlay(bool play, double speed)
             m_mltProducer->seek(0);
         }
         if (m_mltConsumer->get_int("real_time") != m_qmlView->realTime()) {
-            m_mltConsumer->set("real_time", m_qmlView->realTime());
+            m_mltConsumer->set("real_time", 0);
             m_mltConsumer->set("buffer", 25);
             m_mltConsumer->set("prefill", 1);
-            // Changes to real_time require a consumer restart if running.
-            if (!m_mltConsumer->is_stopped()) {
-                m_mltConsumer->stop();
-            }
+            m_mltConsumer->set("drop_max", 0);
         }
         if (currentSpeed == 0) {
             m_mltConsumer->start();
@@ -757,9 +754,9 @@ void Render::switchPlay(bool play, double speed)
         m_mltConsumer->purge();
         m_mltProducer->set_speed(0.0);
         m_mltConsumer->stop();
-        m_mltConsumer->set("buffer", 0);
+        m_mltConsumer->set("buffer", 25);
         m_mltConsumer->set("prefill", 0);
-        m_mltConsumer->set("real_time", -1);
+        m_mltConsumer->set("real_time", 0);
         m_mltProducer->seek(m_mltConsumer->position() + 1);
     }
 }
@@ -778,13 +775,10 @@ void Render::play(double speed)
         resetZoneMode();
     }
     if (speed != 0 && m_mltConsumer->get_int("real_time") != m_qmlView->realTime()) {
-        m_mltConsumer->set("real_time", m_qmlView->realTime());
+        m_mltConsumer->set("real_time", 0);
         m_mltConsumer->set("buffer", 25);
         m_mltConsumer->set("prefill", 1);
-        // Changes to real_time require a consumer restart if running.
-        if (!m_mltConsumer->is_stopped()) {
-            m_mltConsumer->stop();
-        }
+        m_mltConsumer->set("drop_max", 0);
     }
     if (current_speed == 0) {
         m_mltConsumer->start();
-- 
2.10.2



More information about the kdenlive mailing list