Commit 42a7dc01 authored by Alexandru Băluț's avatar Alexandru Băluț

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.
parent dea38fda
......@@ -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."""
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment