def on_frameScale_value_changed(self, control): if self.updating: return frame = int(control.get_value()) time = process.get_frame_time(self.frame_rate, frame) #print frame, time clock.seek(time)
def __init__(self, space, source, asset_path): self.source = source self.space = space self.add_op = None self.item_manip = None default_streams = source.get_default_streams() self.items = [] commands = [] for i, stream in enumerate(default_streams): # Handle streams with infinite ranges start_pos = stream.defined_range[0] end_pos = stream.defined_range[1] if not start_pos: if not end_pos: start_pos = 0 end_pos = int(round(float(space.rate(stream.stream_type)) * Scene.DEFAULT_LENGTH_SECONDS)) else: start_pos = int(round(float(end_pos) - float(space.rate(stream.stream_type)) * Scene.DEFAULT_LENGTH_SECONDS)) else: end_pos = int(round(float(start_pos) + float(space.rate(stream.stream_type)) * Scene.DEFAULT_LENGTH_SECONDS)) item = model.Clip(type=stream.stream_type, source=model.AssetStreamRef(asset_path=asset_path, stream=stream.name), x=start_pos, offset=start_pos, length=end_pos - start_pos + 1, y=i * Scene.DEFAULT_HEIGHT, height=Scene.DEFAULT_HEIGHT) if i != 0: # Set two-way anchors to match for defined_range differences offset_ns = (process.get_frame_time(space.rate(item.type()), item.x) - process.get_frame_time(space.rate(self.items[0].type()), self.items[0].x)) item.update(anchor=model.Anchor(target=self.items[0], offset_ns=offset_ns, two_way=True)) self.items.append(item) commands.append(model.InsertItemCommand(space, item, i)) self.add_commands = commands
def set_current_frame(self, frame): ''' view.set_current_frame(frame) Moves the view's current frame marker. ''' self._invalidate_marker(self.frame) self.frame = frame self._invalidate_marker(frame) self.ruler.set_current_frame(frame) self.uimgr.seek(process.get_frame_time(self.scene().frame_rate, int(frame)))
def handle_update_frames(self, min_frame, max_frame): if not self.space_asset: return # If the current frame was in this set, re-seek to it speed = self.uimgr.get_playback_speed() if speed.numerator: return time = self.uimgr.get_presentation_time() frame = process.get_time_frame(self.space_asset.space.video_format.frame_rate, time) if frame >= min_frame and frame <= max_frame: self.uimgr.seek(process.get_frame_time(self.space_asset.space.video_format.frame_rate, int(frame)))