Skip to content

collect_otio_timeline

CollectOTIOTimeline

Bases: ContextPlugin

Inject the otio timeline

Source code in client/ayon_hiero/plugins/publish/collect_otio_timeline.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
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
class CollectOTIOTimeline(pyblish.api.ContextPlugin):
    """Inject the otio timeline"""

    label = "Collect OTIO Timeline"
    hosts = ["hiero"]
    order = pyblish.api.CollectorOrder - 0.491

    def process(self, context):
        host = registered_host()
        current_file = host.get_current_workfile()

        otio_timeline = hiero_export.create_otio_timeline()

        active_timeline = hiero.ui.activeSequence()
        project = active_timeline.project()
        fps = active_timeline.framerate().toFloat()

        all_tracks = active_timeline.videoTracks()
        tracks_effect_items = self.collect_sub_track_items(all_tracks)

        context_data = {
            "activeProject": project,
            "activeTimeline": active_timeline,
            "currentFile": current_file,
            "otioTimeline": otio_timeline,
            "colorspace": self.get_colorspace(project),
            "fps": fps,
            "tracksEffectItems": tracks_effect_items,
        }
        context.data.update(context_data)

    def get_colorspace(self, project):
        # get workfile's colorspace properties
        return {
            "useOCIOEnvironmentOverride": project.useOCIOEnvironmentOverride(),
            "lutSetting16Bit": project.lutSetting16Bit(),
            "lutSetting8Bit": project.lutSetting8Bit(),
            "lutSettingFloat": project.lutSettingFloat(),
            "lutSettingLog": project.lutSettingLog(),
            "lutSettingViewer": project.lutSettingViewer(),
            "lutSettingWorkingSpace": project.lutSettingWorkingSpace(),
            "lutUseOCIOForExport": project.lutUseOCIOForExport(),
            "ocioConfigName": project.ocioConfigName(),
            "ocioConfigPath": project.ocioConfigPath()
        }

    @staticmethod
    def collect_sub_track_items(tracks):
        """
        Args:
            tracks (list): All of the video tracks.

        Returns:
            dict. Track index as key and list of subtracks
        """
        # collect all subtrack items
        sub_track_items = {}
        for track in tracks:
            effect_items = track.subTrackItems()

            # skip if no clips on track > need track with effect only
            if not effect_items:
                continue

            # skip all disabled tracks
            if not track.isEnabled():
                continue

            track_index = track.trackIndex()
            _sub_track_items = lib.flatten(effect_items)

            _sub_track_items = list(_sub_track_items)
            # continue only if any subtrack items are collected
            if not _sub_track_items:
                continue

            enabled_sti = []
            # loop all found subtrack items and check if they are enabled
            for _sti in _sub_track_items:
                # checking if not enabled
                if not _sti.isEnabled():
                    continue
                if isinstance(_sti, hiero.core.Annotation):
                    continue
                # collect the subtrack item
                enabled_sti.append(_sti)

            # continue only if any subtrack items are collected
            if not enabled_sti:
                continue

            # add collection of subtrackitems to dict
            sub_track_items[track_index] = enabled_sti

        return sub_track_items

collect_sub_track_items(tracks) staticmethod

Parameters:

Name Type Description Default
tracks list

All of the video tracks.

required

Returns:

Type Description

dict. Track index as key and list of subtracks

Source code in client/ayon_hiero/plugins/publish/collect_otio_timeline.py
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
@staticmethod
def collect_sub_track_items(tracks):
    """
    Args:
        tracks (list): All of the video tracks.

    Returns:
        dict. Track index as key and list of subtracks
    """
    # collect all subtrack items
    sub_track_items = {}
    for track in tracks:
        effect_items = track.subTrackItems()

        # skip if no clips on track > need track with effect only
        if not effect_items:
            continue

        # skip all disabled tracks
        if not track.isEnabled():
            continue

        track_index = track.trackIndex()
        _sub_track_items = lib.flatten(effect_items)

        _sub_track_items = list(_sub_track_items)
        # continue only if any subtrack items are collected
        if not _sub_track_items:
            continue

        enabled_sti = []
        # loop all found subtrack items and check if they are enabled
        for _sti in _sub_track_items:
            # checking if not enabled
            if not _sti.isEnabled():
                continue
            if isinstance(_sti, hiero.core.Annotation):
                continue
            # collect the subtrack item
            enabled_sti.append(_sti)

        # continue only if any subtrack items are collected
        if not enabled_sti:
            continue

        # add collection of subtrackitems to dict
        sub_track_items[track_index] = enabled_sti

    return sub_track_items