[pitivi/wip-speed-control: 2/2] pipeline: Use GES frame APIs to do frame stepping
- From: Alexandru Băluț <alexbalut src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi/wip-speed-control: 2/2] pipeline: Use GES frame APIs to do frame stepping
- Date: Sun, 31 Jan 2021 08:04:44 +0000 (UTC)
commit 043e5ead40e320671c8b8b65df2bf64a6ad39e70
Author: Thibault Saunier <tsaunier igalia com>
Date: Wed May 27 18:42:56 2020 -0400
pipeline: Use GES frame APIs to do frame stepping
pitivi/timeline/timeline.py | 4 ++--
pitivi/utils/pipeline.py | 18 ++++++------------
2 files changed, 8 insertions(+), 14 deletions(-)
---
diff --git a/pitivi/timeline/timeline.py b/pitivi/timeline/timeline.py
index 930474ad1..e22d5e5d2 100644
--- a/pitivi/timeline/timeline.py
+++ b/pitivi/timeline/timeline.py
@@ -2174,12 +2174,12 @@ class TimelineContainer(Gtk.Grid, Zoomable, Loggable):
self.timeline.scroll_to_playhead(align=Gtk.Align.CENTER, when_not_in_view=True)
def _seek_backward_one_frame_cb(self, unused_action, unused_parameter):
- self._project.pipeline.step_frame(self._project.videorate, -1)
+ self._project.pipeline.step_frame(-1)
self.timeline.scroll_to_playhead(align=Gtk.Align.CENTER, when_not_in_view=True)
def _seek_forward_one_frame_cb(self, unused_action, unused_parameter):
- self._project.pipeline.step_frame(self._project.videorate, 1)
+ self._project.pipeline.step_frame(1)
self.timeline.scroll_to_playhead(align=Gtk.Align.CENTER, when_not_in_view=True)
def do_focus_in_event(self, unused_event):
diff --git a/pitivi/utils/pipeline.py b/pitivi/utils/pipeline.py
index d389ba906..08078ed39 100644
--- a/pitivi/utils/pipeline.py
+++ b/pitivi/utils/pipeline.py
@@ -577,13 +577,12 @@ class Pipeline(GES.Pipeline, SimplePipeline):
return GES.Pipeline.do_change_state(self, state)
- def step_frame(self, framerate, frames_offset):
+ def step_frame(self, frames_offset):
"""Seeks backwards or forwards the specified amount of frames.
This clamps the playhead to the project frames.
Args:
- framerate (Gst.Fraction): The framerate of the project.
frames_offset (int): The number of frames to step. Negative number
for stepping backwards.
"""
@@ -594,16 +593,11 @@ class Pipeline(GES.Pipeline, SimplePipeline):
"Couldn't get position (you're framestepping too quickly), ignoring this request")
return
- cur_frame = int(
- round(position * framerate.num / float(Gst.SECOND * framerate.denom), 2))
- new_frame = cur_frame + frames_offset
- new_pos = int(new_frame * Gst.SECOND * framerate.denom / framerate.num) + \
- int((Gst.SECOND * framerate.denom / framerate.num) / 2)
- Loggable.info(self, "From frame %d to %d at %f fps, seek to %s s",
- cur_frame,
- new_frame,
- framerate.num / framerate.denom,
- new_pos / float(Gst.SECOND))
+ cur_frame = self.props.timeline.get_frame_at(position)
+ new_frame = max(0, cur_frame + frames_offset)
+ new_pos = self.props.timeline.get_frame_time(new_frame)
+ self.info("From frame %d to %d - seek to %s",
+ cur_frame, new_frame, new_pos)
self.simple_seek(new_pos)
def simple_seek(self, position):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]