def _create_track(in_seq, context=None): context = context or {} new_seq = commands.newNode("RVSequenceGroup", str(in_seq.name or "track")) extra_commands.setUIName(new_seq, str(in_seq.name or "track")) items_to_serialize = otio.algorithms.track_with_expanded_transitions( in_seq) with set_context(context, track_kind=in_seq.kind): new_inputs = [] for thing in items_to_serialize: if isinstance(thing, tuple): result = _create_transition(*thing, context=context) elif thing.duration().value == 0: continue else: result = create_rv_node_from_otio(thing, context) if result: new_inputs.append(result) commands.setNodeInputs(new_seq, new_inputs) _add_metadata_to_node(in_seq, new_seq) return new_seq
def _create_item(it, context=None): context = context or {} range_to_read = it.trimmed_range() if not range_to_read: raise otio.exceptions.OTIOError("No valid range on clip: {0}.".format( str(it))) new_media = _create_media_reference(it, context) if not new_media: kind = "smptebars" if isinstance(it, otio.schema.Gap): kind = "blank" new_media = [_create_movieproc(range_to_read, kind)] try: src = commands.addSourceVerbose(new_media) except Exception as e: # Perhaps the media was missing, if so, lets load an error # source print('ERROR: {}'.format(e)) error_media = _create_movieproc(range_to_read, 'smptebars') src = commands.addSourceVerbose([error_media]) src_group = commands.nodeGroup(src) extra_commands.setUIName(src_group, str(it.name or "clip")) # Add otio metadata to this group and the source _add_metadata_to_node(it, src_group) if hasattr(it, "media_reference") and it.media_reference: _add_metadata_to_node(it.media_reference, src) in_frame = out_frame = None if hasattr(it, "media_reference") and it.media_reference: if isinstance(it.media_reference, otio.schema.ImageSequenceReference): in_frame, out_frame = \ it.media_reference.frame_range_for_time_range( range_to_read ) _add_source_bounds(it.media_reference, src, context) if not in_frame and not out_frame: # because OTIO has no global concept of FPS, the rate of the duration # is used as the rate for the range of the source. in_frame = otio.opentime.to_frames(range_to_read.start_time, rate=range_to_read.duration.rate) out_frame = otio.opentime.to_frames(range_to_read.end_time_inclusive(), rate=range_to_read.duration.rate) commands.setIntProperty(src + ".cut.in", [in_frame]) commands.setIntProperty(src + ".cut.out", [out_frame]) commands.setFloatProperty(src + ".group.fps", [float(range_to_read.duration.rate)]) return src_group
def _create_item(it, track_kind=None): range_to_read = it.trimmed_range() if not range_to_read: raise otio.exceptions.OTIOError( "No valid range on clip: {0}.".format( str(it) ) ) new_media = _create_media_reference(it, track_kind) if not new_media: kind = "smptebars" if isinstance(it, otio.schema.Gap): kind = "blank" new_media = [_create_movieproc(range_to_read, kind)] try: src = commands.addSourceVerbose(new_media) except Exception as e: # Perhaps the media was missing, if so, lets load an error # source print('ERROR: {}'.format(e)) error_media = _create_movieproc(range_to_read, 'smptebars') src = commands.addSourceVerbose([error_media]) src_group = commands.nodeGroup(src) extra_commands.setUIName(src_group, str(it.name or "clip")) # Add otio metadata to this group and the source _add_metadata_to_node(it, src_group) if hasattr(it, "media_reference") and it.media_reference: _add_metadata_to_node(it.media_reference, src) # because OTIO has no global concept of FPS, the rate of the duration is # used as the rate for the range of the source. # RationalTime.value_rescaled_to returns the time value of the object in # time rate of the argument. cut_in = range_to_read.start_time.value_rescaled_to( range_to_read.duration ) commands.setIntProperty(src + ".cut.in", [int(cut_in)]) cut_out = range_to_read.end_time_inclusive().value_rescaled_to( range_to_read.duration ) commands.setIntProperty(src + ".cut.out", [int(cut_out)]) commands.setFloatProperty(src + ".group.fps", [float(range_to_read.duration.rate)]) return src_group
def _create_stack(in_stack, context=None): new_stack = commands.newNode("RVStackGroup", in_stack.name or "tracks") extra_commands.setUIName(new_stack, str(in_stack.name or "tracks")) new_inputs = [] for seq in in_stack: result = create_rv_node_from_otio(seq, context) if result: new_inputs.append(result) commands.setNodeInputs(new_stack, new_inputs) _add_metadata_to_node(in_stack, new_stack) return new_stack
def _create_dissolve(pre_item, in_dissolve, post_item, track_kind=None): rv_trx = commands.newNode("CrossDissolve", in_dissolve.name or "dissolve") extra_commands.setUIName(rv_trx, str(in_dissolve.name or "dissolve")) commands.setFloatProperty(rv_trx + ".parameters.startFrame", [1.0], True) num_frames = (in_dissolve.in_offset + in_dissolve.out_offset).rescaled_to( pre_item.trimmed_range().duration.rate ).value commands.setFloatProperty(rv_trx + ".parameters.numFrames", [float(num_frames)], True) commands.setFloatProperty(rv_trx + ".output.fps", [float(pre_item.trimmed_range().duration.rate)], True) pre_item_rv = create_rv_node_from_otio(pre_item, track_kind) post_item_rv = create_rv_node_from_otio(post_item, track_kind) node_to_insert = post_item_rv if ( hasattr(pre_item, "media_reference") and pre_item.media_reference and pre_item.media_reference.available_range and hasattr(post_item, "media_reference") and post_item.media_reference and post_item.media_reference.available_range and ( post_item.media_reference.available_range.start_time.rate != pre_item.media_reference.available_range.start_time.rate ) ): # write a retime to make sure post_item is in the timebase of pre_item rt_node = commands.newNode("Retime", "transition_retime") rt_node.setTargetFps( pre_item.media_reference.available_range.start_time.rate ) post_item_rv = create_rv_node_from_otio(post_item, track_kind) rt_node.addInput(post_item_rv) node_to_insert = rt_node commands.setNodeInputs(rv_trx, [pre_item_rv, node_to_insert]) _add_metadata_to_node(in_dissolve, rv_trx) return rv_trx