Esempio n. 1
0
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
Esempio n. 2
0
	def changeOrder(self):
		"""docstring for changeOrder"""
		sources = []
		for i in range( self.viewLayers_lw.count() ):
			item = self.viewLayers_lw.item( i )
			sourNode = item.data(32)[0]
			assGroup = commands.nodeGroup(sourNode)
			sources.append( str( assGroup ) )
		commands.setNodeInputs("defaultStack", sources)
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
Esempio n. 4
0
	def addLayer(self):
		"""docstring for fname"""
		stacks = commands.nodesOfType("RVStackGroup")
		commands.setViewNode( stacks[0] )
		layer = self._selectedRender
		version = self._selectedVersion
		sqfFil = sqf.sequenceFile( layer + '/' + version + '/' + self._selectedLayer + '.exr' )
		asd = commands.addSourceVerbose( [layer + '/' + version + '/' + self._selectedLayer + '.' + str(sqfFil.start) + '-' + str(sqfFil.end) + '#.exr'], None )
		assGroup = commands.nodeGroup(asd)
		commands.setStringProperty(assGroup + '.ui.name', [self._selectedShot.name + ' - ' + self._selectedLayer + ' - ' + version])
		item = QtGui.QListWidgetItem(self._selectedShot.name + ' - ' + self._selectedLayer + ' - ' + version )
		item.setCheckState( QtCore.Qt.Checked )
		item.setData(32, [asd, [sqfFil, self._selectedShot, self._selectedLayer, version ]] )
		self.viewLayers_lw.addItem( item )
    def _get_node_for_source(self, node_type):
        """
        Finds the node of the given type for the currently viewed
        source.
        
        :param str node_type: RV node type, eg. RVColor, RVCDL
        """
        # first find the source for the frame we're currently viewing
        frame = commands.frame()
        # file_source = None
        for source in extra_commands.nodesInEvalPath(frame, "RVFileSource", None):
            file_source = source
            continue

        source_group = commands.nodeGroup(file_source)
        
        # now find the node of the given type for that source
        pipe_node  = group_member_of_type(source_group, "RVLookPipelineGroup")
        return group_member_of_type(pipe_node, node_type)
Esempio n. 6
0
    def expand_sources(self):
        """
        Expand any movie movieproc otioFile sources.
        """
        # disable caching for load speed
        cache_mode = commands.cacheMode()
        commands.setCacheMode(commands.CacheOff)

        try:
            # find sources with a movieproc with an otioFile=foo.otio tag
            default_inputs, _ = commands.nodeConnections('defaultSequence')
            for src in commands.nodesOfType('RVSource'):
                src_group = commands.nodeGroup(src)
                if src_group not in default_inputs:
                    # not in default sequence, already processed
                    continue

                # get the source file name
                paths = [
                    info['file'] for info in commands.sourceMediaInfoList(src)
                    if 'file' in info
                ]
                for info_path in paths:
                    # Looking for: 'blank,otioFile=/foo.otio.movieproc'
                    parts = info_path.split("=", 1)
                    itype = parts[0]
                    if not itype.startswith('blank,otioFile'):
                        continue
                    # remove the .movieproc extension
                    path, _ = os.path.splitext(parts[1])

                    # remove temp movieproc source from current view, and all
                    # the default views
                    _remove_source_from_views(src_group)

                    result = otio_reader.read_otio_file(path)
                    commands.setViewNode(result)
                    break
        finally:
            # turn cache mode back on and go back to sleep
            commands.setCacheMode(cache_mode)
            self.mode = Mode.sleeping
Esempio n. 7
0
	def removeLayer(self):
		"""docstring for fname"""
		lay = self.viewLayers_lw.selectedItems()[0]
		self.viewLayers_lw.takeItem( self.viewLayers_lw.row( lay ) )
		assGroup = commands.nodeGroup(lay.data(32)[0])
		commands.deleteNode( assGroup )
 def get_group(self):
     return Group(commands.nodeGroup(self.name))
Esempio n. 9
-1
    def add_audio(self, event):
        """Ask the user for a file and add it as audio to the currently selected sequences."""
        # The idea here is to use RVs stack to create two "tracks". The first input will be a
        # sequence of all the current sources, and the second the selected audio file.
        selected_files = commands.openMediaFileDialog(False, commands.OneExistingFile, "", "", "")

        # Find all the sources connected to the current sequence, and save them for later.
        current_sources = []
        current_sequence = commands.viewNode()
        inputs, _ = commands.nodeConnections(current_sequence, False)
        for node in inputs:
            if commands.nodeType(node) == "RVSourceGroup":
                current_sources.append(node)

        # Create a new source for the selected file. We'll do this here to fail early
        # and not leave junk nodes laying around.
        audio_source = commands.addSourceVerbose([selected_files[0]], "")
        audio_group = commands.nodeGroup(audio_source)

        # Create a new sequence and connect the sources. We're assuming here that the current sequence 
        # is the default sequence, which always contains all sources known to RV. We'll need our own copy 
        # since we want to keep the audio out of our "video track".
        sequence = commands.newNode("RVSequenceGroup", "SequenceForAudioStack")
        commands.setNodeInputs(sequence, current_sources)

        # Create the stack and connect the two sources.
        stack = commands.newNode("RVStackGroup", "StackWithAudio")
        commands.setNodeInputs(stack, [sequence, audio_group])

        # Find the actual stack node and configure it to to use the topmost 
        # source (no compositing) and only the audio we just loaded. This should mean
        # that if the user selects a file containing both audio and video as the audio
        # source, they will still get the expected result.
        for node in commands.nodesInGroup(stack):
            if commands.nodeType(node) == "RVStack":
                commands.setStringProperty("%s.composite.type" % (node), ["topmost"], False)
                commands.setStringProperty("%s.output.chosenAudioInput" % (node), [audio_group], False)
                break

        commands.setViewNode(stack)