How to use the opentimelineio.schema 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_item.py View on Github external
),
                        ),
                        otio.schema.Clip(
                            name="B",
                            source_range=otio.opentime.TimeRange(
                                start_time=otio.opentime.RationalTime(
                                    value=100,
                                    rate=30
                                ),
                                duration=otio.opentime.RationalTime(
                                    value=50,
                                    rate=30
                                )
                            )
                        ),
                        otio.schema.Transition(
                            in_offset=otio.opentime.RationalTime(
                                value=17,
                                rate=30
                            ),
                            out_offset=otio.opentime.RationalTime(
                                value=15,
                                rate=30
                            ),
                        ),
                        otio.schema.Clip(
                            name="C",
                            source_range=otio.opentime.TimeRange(
                                start_time=otio.opentime.RationalTime(
                                    value=50,
                                    rate=30
                                ),
github PixarAnimationStudios / OpenTimelineIO / tests / test_item.py View on Github external
def test_visible_range(self):
        timeline = otio.schema.Timeline(
            tracks=[
                otio.schema.Track(
                    name="V1",
                    children=[
                        otio.schema.Clip(
                            name="A",
                            source_range=otio.opentime.TimeRange(
                                start_time=otio.opentime.RationalTime(
                                    value=1,
                                    rate=30
                                ),
                                duration=otio.opentime.RationalTime(
                                    value=50,
                                    rate=30
                                )
                            )
                        ),
                        otio.schema.Transition(
github PixarAnimationStudios / OpenTimelineIO / tests / test_serializable_collection.py View on Github external
def test_iterable(self):
        self.assertEqual(self.sc[0], self.children[0])
        self.assertEqual([i for i in self.sc], self.children)
        self.assertEqual(len(self.sc), 2)

        # test recursive iteration
        sc = otio.schema.SerializableCollection(
            name="parent",
            children=[self.sc]
        )

        self.assertEqual(len(list(sc.each_clip())), 1)

        # test deleting an item
        tmp = self.sc[0]
        del self.sc[0]
        self.assertEqual(len(self.sc), 1)
        self.sc[0] = tmp
        self.assertEqual(self.sc[0], tmp)
github PixarAnimationStudios / OpenTimelineIO / tests / test_composition.py View on Github external
zero = otio.opentime.RationalTime(0, 24)
        one = otio.opentime.RationalTime(1, 24)
        fifty = otio.opentime.RationalTime(50, 24)
        ninetynine = otio.opentime.RationalTime(99, 24)
        onehundred = otio.opentime.RationalTime(100, 24)
        top_level_range = otio.opentime.TimeRange(
            start_time=zero, duration=onehundred)

        # here are some times in the media-level coordinate system
        first_frame = otio.opentime.RationalTime(100, 24)
        middle = otio.opentime.RationalTime(150, 24)
        last = otio.opentime.RationalTime(199, 24)
        media_range = otio.opentime.TimeRange(
            start_time=first_frame, duration=onehundred)

        timeline = otio.schema.Timeline()
        stack = timeline.tracks
        track = otio.schema.Track()
        clip = otio.schema.Clip()
        media = otio.schema.MissingReference()
        media.available_range = media_range
        clip.media_reference = media
        track.append(clip)
        stack.append(track)

        self.assertIs(track, clip.parent())
        self.assertIs(stack, track.parent())

        # the clip and track should auto-size to fit the media, since we
        # haven't trimmed anything
        self.assertEqual(clip.duration(), onehundred)
        self.assertEqual(track.duration(), onehundred)
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / application_plugins / rv / example_otio_reader / otio_reader.py View on Github external
def create_rv_node_from_otio(otio_obj, track_kind=None):
    WRITE_TYPE_MAP = {
        otio.schema.Timeline: _create_timeline,
        otio.schema.Stack: _create_stack,
        otio.schema.Track: _create_track,
        otio.schema.Clip: _create_item,
        otio.schema.Gap: _create_item,
        otio.schema.Transition: _create_transition,
        otio.schema.SerializableCollection: _create_collection,
    }

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

    raise NoMappingForOtioTypeError(
        str(type(otio_obj)) + " on object: {}".format(otio_obj)
    )
github PixarAnimationStudios / OpenTimelineIO / src / opentimelineview / track_widgets.py View on Github external
0,
                0,
                otio.opentime.to_seconds(timeline_range.duration) *
                TIME_MULTIPLIER,
                TRACK_HEIGHT
            )

            if isinstance(item, otio.schema.Clip):
                new_item = ClipItem(item, timeline_range, rect)
            elif isinstance(item, otio.schema.Stack):
                new_item = NestedItem(item, timeline_range, rect)
            elif isinstance(item, otio.schema.Track):
                new_item = NestedItem(item, timeline_range, rect)
            elif isinstance(item, otio.schema.Gap):
                new_item = GapItem(item, timeline_range, rect)
            elif isinstance(item, otio.schema.Transition):
                new_item = TransitionItem(item, timeline_range, rect)
            else:
                print("Warning: could not add item {} to UI.".format(item))
                continue

            new_item.setParentItem(self)
            new_item.setX(
                otio.opentime.to_seconds(timeline_range.start_time) *
                TIME_MULTIPLIER
            )
            new_item.counteract_zoom()
github PixarAnimationStudios / OpenTimelineIO / examples / shot_detect.py View on Github external
def _timeline_with_breaks(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)

    out, _ = _ffprobe_output(name, full_path, dryrun)

    if dryrun:
        return ("", "")

    # saving time in base 1.0 to demonstrate that you can
    playhead = otio.opentime.RationalTime(0, 1.0)
    shot_index = 1
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / extern_rv.py View on Github external
def _create_media_reference(item, src, track_kind=None):
    if hasattr(item, "media_reference") and item.media_reference:
        if isinstance(item.media_reference, otio.schema.ExternalReference):
            media = [str(item.media_reference.target_url)]

            if track_kind == otio.schema.TrackKind.Audio:
                # Create blank video media to accompany audio for valid source
                blank = "{},start={},end={},fps={}.movieproc".format(
                    "blank",
                    item.available_range().start_time.value,
                    item.available_range().end_time_inclusive().value,
                    item.available_range().duration.rate
                )
                # Inserting blank media here forces all content to only
                # produce audio. We do it twice in case we look at this in
                # stereo
                media = [blank, blank] + media

            src.setMedia(media)
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / extern_rv.py View on Github external
def _create_media_reference(item, src, track_kind=None):
    if hasattr(item, "media_reference") and item.media_reference:
        if isinstance(item.media_reference, otio.schema.ExternalReference):
            media = [str(item.media_reference.target_url)]

            if track_kind == otio.schema.TrackKind.Audio:
                # Create blank video media to accompany audio for valid source
                blank = "{},start={},end={},fps={}.movieproc".format(
                    "blank",
                    item.available_range().start_time.value,
                    item.available_range().end_time_inclusive().value,
                    item.available_range().duration.rate
                )
                # Inserting blank media here forces all content to only
                # produce audio. We do it twice in case we look at this in
                # stereo
                media = [blank, blank] + media

            src.setMedia(media)
            return True

        elif isinstance(item.media_reference, otio.schema.GeneratorReference):
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / aaf_adapter / aaf_writer.py View on Github external
def aaf_transition(self, otio_transition):
        """Convert an otio Transition into an aaf Transition"""
        if (otio_transition.transition_type !=
                otio.schema.TransitionTypes.SMPTE_Dissolve):
            print(
                "Unsupported transition type: {}".format(
                    otio_transition.transition_type))
            return None

        transition_params, varying_value = self._transition_parameters()

        interpolation_def = self.aaf_file.create.InterpolationDef(
            aaf2.misc.LinearInterp, "LinearInterp", "Linear keyframe interpolation")
        self.aaf_file.dictionary.register_def(interpolation_def)
        varying_value["Interpolation"].value = (
            self.aaf_file.dictionary.lookup_interperlationdef("LinearInterp"))

        pointlist = otio_transition.metadata["AAF"]["PointList"]

        c1 = self.aaf_file.create.ControlPoint()