How to use the opentimelineio.schema.Timeline function in OpenTimelineIO

To help you get started, we’ve selected a few OpenTimelineIO examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PixarAnimationStudios / OpenTimelineIO / tests / test_cmx_3600_adapter.py View on Github external
def test_edl_round_trip_mem2disk2mem(self):
        track = otio.schema.Track()
        tl = otio.schema.Timeline("test_timeline", tracks=[track])
        rt = otio.opentime.RationalTime(5.0, 24.0)
        mr = otio.schema.ExternalReference(target_url="/var/tmp/test.mov")
        md = {
            "cmx_3600": {
                "reel": "test",
                "comments": ["OTIO TRUNCATED REEL NAME FROM: test.mov"]
            }
        }

        tr = otio.opentime.TimeRange(
            start_time=otio.opentime.RationalTime(0.0, 24.0),
            duration=rt
        )

        cl = otio.schema.Clip(
            name="test clip1",
github PixarAnimationStudios / OpenTimelineIO / tests / test_timeline.py View on Github external
def test_tracks(self):
        tl = otio.schema.Timeline(tracks=[
            otio.schema.Track(
                name="V1",
                kind=otio.schema.TrackKind.Video
            ),
            otio.schema.Track(
                name="V2",
                kind=otio.schema.TrackKind.Video
            ),
            otio.schema.Track(
                name="A1",
                kind=otio.schema.TrackKind.Audio
            ),
            otio.schema.Track(
                name="A2",
                kind=otio.schema.TrackKind.Audio
            ),
github PixarAnimationStudios / OpenTimelineIO / tests / test_timeline.py View on Github external
def test_metadata(self):
        rt = otio.opentime.RationalTime(12, 24)
        tl = otio.schema.Timeline("test_timeline", global_start_time=rt)
        tl.metadata['foo'] = "bar"
        self.assertEqual(tl.metadata['foo'], 'bar')

        encoded = otio.adapters.otio_json.write_to_string(tl)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(tl, decoded)
        self.assertEqual(tl.metadata, decoded.metadata)
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / extern_maya_sequencer.py View on Github external
def read_sequence():
    rate = FPS.get(cmds.currentUnit(q=True, time=True), 25)
    shots = cmds.ls(type='shot') or []
    per_track = {}

    for shot in shots:
        track_no = cmds.shot(shot, q=True, track=True)
        if track_no not in per_track:
            per_track[track_no] = []
        per_track[track_no].append(shot)

    timeline = otio.schema.Timeline()
    timeline.global_start_time = otio.opentime.RationalTime(0, rate)

    for track_no in reversed(sorted(per_track.keys())):
        track_shots = per_track[track_no]
        timeline.tracks.append(_read_track(track_shots))

    return timeline
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / fcpx_xml.py View on Github external
def _from_project(self, project_element):
        timeline = otio.schema.Timeline(name=project_element.get("name", ""))
        timeline.tracks = self._squence_to_stack(
            project_element.find("./sequence", {})
        )
        return timeline
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / advanced_authoring_format.py View on Github external
# Gather all the Master Mobs, so we can find them later by MobID
        # when we parse the SourceClips in the composition
        if masterMobs is None:
            masterMobs = {}
        for mob in item.mastermobs():
            child = _transcribe(mob, parents + [item], editRate, masterMobs)
            if child is not None:
                mobID = child.metadata.get("AAF", {}).get("MobID")
                masterMobs[mobID] = child

        for mob in item.compositionmobs():
            child = _transcribe(mob, parents + [item], editRate, masterMobs)
            _add_child(result, child, mob)

    elif isinstance(item, aaf2.mobs.Mob):
        result = otio.schema.Timeline()

        for slot in item.slots:
            track = _transcribe(slot, parents + [item], editRate, masterMobs)
            _add_child(result.tracks, track, slot)

            # Use a heuristic to find the starting timecode from
            # this track and use it for the Timeline's global_start_time
            start_time = _find_timecode_track_start(track)
            if start_time:
                result.global_start_time = start_time

    elif isinstance(item, aaf2.components.SourceClip):
        result = otio.schema.Clip()

        # Evidently the last mob is the one with the timecode
        mobs = _find_timecode_mobs(item)
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / xges.py View on Github external
def to_otio(self):
        """
        Convert an xges to an otio

        Returns:
            OpenTimeline: An OpenTimeline Timeline object
        """
        otio_timeline = otio.schema.Timeline()
        project = self._fill_otio_stack_from_ges(otio_timeline.tracks)
        otio_timeline.name = self._get_from_metadatas(
            project, "name", "string", "")
        return otio_timeline
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / hls_playlist.py View on Github external
def __init__(self, edl_string):
        self.timeline = otio.schema.Timeline()
        self.playlist_type = None

        self._parse_playlist(edl_string)
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / extern_rv.py View on Github external
def write_otio(otio_obj, to_session, track_kind=None):
    WRITE_TYPE_MAP = {
        otio.schema.Timeline: _write_timeline,
        otio.schema.Stack: _write_stack,
        otio.schema.Track: _write_track,
        otio.schema.Clip: _write_item,
        otio.schema.Gap: _write_item,
        otio.schema.Transition: _write_transition,
        otio.schema.SerializableCollection: _write_collection,
    }

    if type(otio_obj) in WRITE_TYPE_MAP:
        return WRITE_TYPE_MAP[type(otio_obj)](otio_obj, to_session, track_kind)

    raise NoMappingForOtioTypeError(
        str(type(otio_obj)) + " on object: {}".format(otio_obj)
    )
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / fcpx_xml.py View on Github external
def __init__(self, otio_timeline):
        self.otio_timeline = otio_timeline
        self.fcpx_xml = cElementTree.Element("fcpxml", version="1.8")
        self.resource_element = cElementTree.SubElement(
            self.fcpx_xml,
            "resources"
        )
        if self.otio_timeline.schema_name() == "Timeline":
            self.timelines = [self.otio_timeline]
        else:
            self.timelines = list(
                self.otio_timeline.each_child(
                    descended_from_type=otio.schema.Timeline
                )
            )

        if len(self.timelines) > 1:
            self.event_resource = cElementTree.SubElement(
                self.fcpx_xml,
                "event",
                {"name": self._event_name()}
            )
        else:
            self.event_resource = self.fcpx_xml

        self.resource_count = 0