[pitivi] viewer: Improve trim preview precision and latency



commit 42a7dc01e642d642d48b55d4d40a2ccbcdddbe2a
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed Jan 16 09:23:58 2019 +0100

    viewer: Improve trim preview precision and latency
    
    The `clipTrimPreview` method is called whenever the clip trim updates,
    and until now it was ignoring updates if the last performed seek was too
    recent. This means the trim preview was up to 200ms old when the mouse
    stopped moving.
    
    If we want to not seek more often than 200ms, we'd have to add a timeout
    in case an unwanted seek is desired, and at the end of the timeout
    perform the latest wanted seek. This would be more accurate, since the
    preview would be less than 200ms behind, but it would still be laggy.
    
    To remove the lag, we shall simply seek. The `SimplePipeline.simple_seek`
    method is async and already knows to skip seeks not yet performed in
    case a new one is wanted.

 pitivi/viewer/viewer.py | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)
---
diff --git a/pitivi/viewer/viewer.py b/pitivi/viewer/viewer.py
index aa727bef..49cde960 100644
--- a/pitivi/viewer/viewer.py
+++ b/pitivi/viewer/viewer.py
@@ -17,7 +17,6 @@
 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 from gettext import gettext as _
-from time import time
 
 from gi.repository import Gdk
 from gi.repository import GES
@@ -518,21 +517,16 @@ class ViewerContainer(Gtk.Box, Loggable):
             self.log("Not previewing trim for image or title clip: %s", clip)
             return False
 
-        clip_uri = clip.props.uri
-        cur_time = time()
         if self.pipeline == self.app.project_manager.current_project.pipeline:
             self.debug("Creating temporary pipeline for clip %s, position %s",
-                       clip_uri, format_ns(position))
+                       clip.props.uri, format_ns(position))
             self._oldTimelinePos = self.pipeline.getPosition(False)
             self.pipeline.set_state(Gst.State.NULL)
             self.setPipeline(AssetPipeline(clip))
             self.__owning_pipeline = True
-            self._lastClipTrimTime = cur_time
 
-        if (cur_time - self._lastClipTrimTime) > 0.2 and self.pipeline.getState() == Gst.State.PAUSED:
-            # Do not seek more than once every 200 ms (for performance)
-            self.pipeline.simple_seek(position)
-            self._lastClipTrimTime = cur_time
+        self.pipeline.simple_seek(position)
+        return False
 
     def clipTrimPreviewFinished(self):
         """Switches back to the project pipeline following a clip trimming."""


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]