Skip to content

load_mov

MovLoader

Bases: LoaderPlugin

Load mov into OpenRV

Source code in client/ayon_openrv/plugins/load/openrv/load_mov.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
class MovLoader(load.LoaderPlugin):
    """Load mov into OpenRV"""

    label = "Load MOV"
    product_types = {"*"}
    representations = {"*"}
    extensions = {"mov", "mp4"}
    order = 0

    icon = "code-fork"
    color = "orange"

    def load(self, context, name=None, namespace=None, data=None):

        filepath = self.filepath_from_context(context)
        namespace = namespace if namespace else context["folder"]["name"]

        loaded_node = rv.commands.addSourceVerbose([filepath])

        # update colorspace
        self.set_representation_colorspace(loaded_node,
                                           context["representation"])

        imprint_container(
            loaded_node,
            name=name,
            namespace=namespace,
            context=context,
            loader=self.__class__.__name__
        )

    def update(self, container, context):
        filepath = self.filepath_from_context(context)

        # change path
        node = container["node"]
        rv.commands.setSourceMedia(node, [filepath])

        # update colorspace
        representation = context["representation"]
        self.set_representation_colorspace(node, representation)

        # update name
        rv.commands.setStringProperty(f"{node}.media.name", ["newname"], True)
        rv.commands.setStringProperty(
            f"{node}.media.repName", ["repname"], True
        )
        rv.commands.setStringProperty(
            f"{node}.openpype.representation", [representation["id"]], True
        )

    def remove(self, container):
        node = container["node"]
        group = rv.commands.nodeGroup(node)
        rv.commands.deleteNode(group)

    def set_representation_colorspace(self, node, representation):
        colorspace_data = representation.get("data", {}).get("colorspaceData")
        if colorspace_data:
            colorspace = colorspace_data["colorspace"]
            # TODO: Confirm colorspace is valid in current OCIO config
            #   otherwise errors will be spammed from OpenRV for invalid space

            self.log.info(f"Setting colorspace: {colorspace}")
            group = rv.commands.nodeGroup(node)

            # Enable OCIO for the node and set the colorspace
            set_group_ocio_active_state(group, state=True)
            set_group_ocio_colorspace(group, colorspace)