How to use the opentimelineio.schema.Transition 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_filter_algorithms.py View on Github external
def test_prune_clips_after_transitions(self):
        """test a reduce that removes clips that follow transitions"""

        md = {'test': 'bar'}
        tr = otio.schema.Track(name='foo', metadata=md)
        for i in range(5):
            ind = str(i)
            if i in (2, 3):
                tr.append(otio.schema.Transition(name='should_be_pruned' + ind))
            tr.append(otio.schema.Clip(name='cl' + ind, metadata=md))

        def no_clips_after_transitions(prev, thing, __):
            if (
                isinstance(prev, otio.schema.Transition) or
                isinstance(thing, otio.schema.Transition)
            ):
                return None
            return thing

        result = otio.algorithms.filtered_with_sequence_context(
            tr,
            no_clips_after_transitions
        )

        # emptying the track of transitions and the clips they follow and
github PixarAnimationStudios / OpenTimelineIO / tests / test_json_backend.py View on Github external
def test_transition(self):
        trx = otio.schema.Transition()
        self.check_against_baseline(trx, "empty_transition")
github PixarAnimationStudios / OpenTimelineIO / tests / test_cmx_3600_adapter.py View on Github external
"Example Fade Out",
            tracks=[track]
        )

        cl = otio.schema.Clip(
            'My Clip',
            metadata={'cmx_3600': {'reel': 'My_Clip'}},
            media_reference=otio.schema.ExternalReference(
                target_url="/var/tmp/clip.001.exr"
            ),
            source_range=otio.opentime.TimeRange(
                start_time=otio.opentime.RationalTime(24.0, 24.0),
                duration=otio.opentime.RationalTime(24.0, 24.0)
            )
        )
        trans = otio.schema.Transition(
            in_offset=otio.opentime.RationalTime(12.0, 24.0),
            out_offset=otio.opentime.RationalTime(0.0, 24.0)
        )
        tl.tracks[0].extend([cl, trans])

        result = otio.adapters.write_to_string(
            tl,
            adapter_name='cmx_3600',
            style='nucoda'
        )

        expected = r'''TITLE: Example Fade Out

001  My_Clip  V     C        00:00:01:00 00:00:01:12 00:00:00:00 00:00:00:12
* FROM CLIP NAME:  My Clip
* FROM FILE: /var/tmp/clip.001.exr
github PixarAnimationStudios / OpenTimelineIO / tests / test_track_algo.py View on Github external
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))

        pre_duration = copy.deepcopy(seq[0].source_range.duration)

        # print
github PixarAnimationStudios / OpenTimelineIO / tests / test_item.py View on Github external
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(
                            in_offset=otio.opentime.RationalTime(
                                value=7,
                                rate=30
                            ),
                            out_offset=otio.opentime.RationalTime(
                                value=10,
                                rate=30
                            ),
                        ),
                        otio.schema.Clip(
                            name="B",
                            source_range=otio.opentime.TimeRange(
                                start_time=otio.opentime.RationalTime(
                                    value=100,
                                    rate=30
                                ),
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / xges.py View on Github external
def _otio_transition_from_clip(self, clip):
        otio_transition = otio.schema.Transition(
            name=self._get_name(clip),
            transition_type=TRANSITION_MAP.get(
                clip.attrib["asset-id"],
                otio.schema.TransitionTypes.Custom))
        self._add_properties_and_metadatas_to_otio(otio_transition, clip)
        return otio_transition
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 / 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)
    )