How to use the opentimelineio.schema.Track 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_composition.py View on Github external
def test_iterating_over_dupes(self):
        timeline = otio.schema.Timeline()
        track = otio.schema.Track()
        timeline.tracks.append(track)
        clip = otio.schema.Clip(
            name="Dupe",
            source_range=otio.opentime.TimeRange(
                start_time=otio.opentime.RationalTime(10, 30),
                duration=otio.opentime.RationalTime(15, 30)
            )
        )

        # make several identical copies
        for i in range(10):
            dupe = copy.deepcopy(clip)
            track.append(dupe)
        self.assertEqual(len(track), 10)
        self.assertEqual(
            otio.opentime.TimeRange(
github PixarAnimationStudios / OpenTimelineIO / tests / test_track_algo.py View on Github external
avail_tr = otio.opentime.TimeRange(
            otio.opentime.RationalTime(0, 24),
            otio.opentime.RationalTime(50, 24)
        )
        mr = otio.schema.ExternalReference(
            available_range=avail_tr,
            target_url="/var/tmp/test.mov"
        )

        cl = otio.schema.Clip(
            name=name + "_pre",
            media_reference=mr,
            source_range=tr,
        )

        seq = otio.schema.Track()
        seq.append(cl)
        in_offset = rt
        out_offset = rt_2
        trx = otio.schema.Transition(
            name="AtoB",
            transition_type=otio.schema.TransitionTypes.SMPTE_Dissolve,
            in_offset=in_offset,
            out_offset=out_offset,
            metadata={
                "foo": "bar"
            }
        )
        seq.append(trx)
        cl_2 = copy.deepcopy(cl)
        cl_2.name = name + "_post"
        seq.append(copy.deepcopy(cl))
github PixarAnimationStudios / OpenTimelineIO / tests / test_composition.py View on Github external
def test_remove_actually_removes(self):
        """Test that removed item is no longer 'in' composition."""
        tr = otio.schema.Track()
        cl = otio.schema.Clip()

        # test inclusion
        tr.append(cl)
        self.assertIn(cl, tr)

        # delete by index
        del tr[0]
        self.assertNotIn(cl, tr)

        # delete by slice
        tr = otio.schema.Track()
        tr.append(cl)
        del tr[:]
        self.assertNotIn(cl, tr)
github PixarAnimationStudios / OpenTimelineIO / tests / test_composition.py View on Github external
def test_repr(self):
        sq = otio.schema.Track(name="foo", children=[])
        self.assertMultiLineEqual(
            repr(sq),
            "otio.schema.Track(" +
            "name=" + repr(sq.name) + ", " +
            "children=" + repr(list(sq)) + ", " +
            "source_range=" + repr(sq.source_range) + ", " +
            "metadata=" + repr(sq.metadata) +
            ")"
        )
github PixarAnimationStudios / OpenTimelineIO / tests / test_composition.py View on Github external
def test_trim_child_range(self):
        for st in [
            otio.schema.Track(name="foo"),
            otio.schema.Stack(name="foo")
        ]:
            st.source_range = otio.opentime.TimeRange(
                start_time=otio.opentime.RationalTime(value=100, rate=24),
                duration=otio.opentime.RationalTime(value=50, rate=24)
            )
            r = otio.opentime.TimeRange(
                start_time=otio.opentime.RationalTime(value=110, rate=24),
                duration=otio.opentime.RationalTime(value=30, rate=24)
            )
            self.assertEqual(st.trim_child_range(r), r)
            r = otio.opentime.TimeRange(
                start_time=otio.opentime.RationalTime(value=0, rate=24),
                duration=otio.opentime.RationalTime(value=30, rate=24)
            )
            self.assertEqual(st.trim_child_range(r), None)
github PixarAnimationStudios / OpenTimelineIO / tests / test_composition.py View on Github external
def test_range_nested(self):
        track = otio.schema.Track(
            name="inner",
            children=[
                otio.schema.Clip(
                    name="clip1",
                    source_range=otio.opentime.TimeRange(
                        start_time=otio.opentime.RationalTime(
                            value=100,
                            rate=24
                        ),
                        duration=otio.opentime.RationalTime(
                            value=50,
                            rate=24
                        )
                    )
                ),
                otio.schema.Clip(
github PixarAnimationStudios / OpenTimelineIO / tests / test_filter_algorithms.py View on Github external
def test_copy(self):
        """Test that a simple reduce results in a copy"""
        md = {'test': 'bar'}
        tl = otio.schema.Timeline(name='foo', metadata=md)
        tl.tracks.append(otio.schema.Track(name='track1', metadata=md))
        tl.tracks[0].append(otio.schema.Clip(name='cl1', metadata=md))

        test = otio.algorithms.filtered_with_sequence_context(
            tl,
            # no op - ignore all arguments and return original thing
            lambda _, thing, __: thing
        )

        # make sure the original timeline didn't get nuked
        self.assertEqual(len(tl.tracks), 1)
        self.assertJsonEqual(tl, test)
github PixarAnimationStudios / OpenTimelineIO / examples / shot_detect.py View on Github external
def _timeline_with_single_clip(name, full_path, dryrun=False):
    timeline = otio.schema.Timeline()
    timeline.name = name
    track = otio.schema.Track()
    track.name = name
    timeline.tracks.append(track)

    fps = _ffprobe_fps(name, full_path, dryrun)
    available_range = _media_start_end_of(full_path, fps)

    media_reference = otio.schema.ExternalReference(
        target_url="file://" + full_path,
        available_range=available_range
    )

    if dryrun:
        return

    clip = otio.schema.Clip(name=name)
    clip.media_reference = media_reference
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / fcpx_xml.py View on Github external
timeline_items.append(
                {
                    "track": lane,
                    "offset": offset,
                    "composable": composable,
                    "audio_only": self._audio_only(element)
                }
            )

            lanes.append(lane)
        sorted_lanes = list(set(lanes))
        sorted_lanes.sort()
        for lane in sorted_lanes:
            sorted_items = self._sorted_items(lane, timeline_items)
            track = otio.schema.Track(
                name=lane,
                kind=self._track_type(sorted_items)
            )

            for item in sorted_items:
                frame_diff = (
                    int(item["offset"].value) - track.duration().value
                )
                if frame_diff > 0:
                    track.append(
                        self._create_gap(
                            0,
                            frame_diff,
                            sequence_element.get("format")
                        )
                    )
github PixarAnimationStudios / OpenTimelineIO / src / py-opentimelineio / opentimelineio / console / otiostat.py View on Github external
def _sequences_with_non_standard_types(input):
    return len(
        list(
            c
            for c in input.each_child(descended_from_type=otio.schema.Track)
            if c.kind not in (otio.schema.TrackKind.__dict__)
        )