How to use the opentimelineio.schema.ExternalReference 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_clip.py View on Github external
def test_cons(self):
        name = "test"
        rt = otio.opentime.RationalTime(5, 24)
        tr = otio.opentime.TimeRange(rt, rt)
        mr = otio.schema.ExternalReference(
            available_range=otio.opentime.TimeRange(
                rt,
                otio.opentime.RationalTime(10, 24)
            ),
            target_url="/var/tmp/test.mov"
        )

        cl = otio.schema.Clip(
            name=name,
            media_reference=mr,
            source_range=tr,
            # transition_in
            # transition_out
        )
        self.assertEqual(cl.name, name)
        self.assertEqual(cl.source_range, tr)
github PixarAnimationStudios / OpenTimelineIO / tests / test_timeline.py View on Github external
def test_iterators(self):
        self.maxDiff = None
        track = otio.schema.Track(name="test_track")
        tl = otio.schema.Timeline("test_timeline", tracks=[track])
        rt = otio.opentime.RationalTime(5, 24)
        mr = otio.schema.ExternalReference(
            available_range=otio.opentime.range_from_start_end_time(
                otio.opentime.RationalTime(5, 24),
                otio.opentime.RationalTime(15, 24)
            ),
            target_url="/var/tmp/test.mov"
        )

        cl = otio.schema.Clip(
            name="test clip1",
            media_reference=mr,
            source_range=otio.opentime.TimeRange(
                mr.available_range.start_time,
                rt
            ),
        )
        cl2 = otio.schema.Clip(
github PixarAnimationStudios / OpenTimelineIO / tests / test_cmx_3600_adapter.py View on Github external
fps = 24
        timeline = otio.adapters.read_from_file(edl_path)
        self.assertTrue(timeline is not None)
        self.assertEqual(len(timeline.tracks), 1)
        self.assertEqual(len(timeline.tracks[0]), 2)
        self.assertEqual(
            timeline.tracks[0][0].name,
            "take_1"
        )
        self.assertEqual(
            timeline.tracks[0][0].source_range.duration,
            otio.opentime.from_timecode("00:00:01:07", fps)
        )
        self.assertIsOTIOEquivalentTo(
            timeline.tracks[0][0].media_reference,
            otio.schema.ExternalReference(
                target_url=r"S:\path\to\ZZ100_501.take_1.0001.exr"
            )
        )
        self.assertEqual(
            timeline.tracks[0][1].name,
            "take_2"
        )
        self.assertEqual(
            timeline.tracks[0][1].source_range.duration,
            otio.opentime.from_timecode("00:00:02:02", fps)
        )
        self.assertIsOTIOEquivalentTo(
            timeline.tracks[0][1].media_reference,
            otio.schema.ExternalReference(
                target_url=r"S:\path\to\ZZ100_502A.take_2.0101.exr"
            )
github PixarAnimationStudios / OpenTimelineIO / tests / test_json_backend.py View on Github external
def test_external_reference(self):
        mr = otio.schema.ExternalReference(target_url="foo.bar")
        self.check_against_baseline(mr, "empty_external_reference")
github PixarAnimationStudios / OpenTimelineIO / tests / test_timeline.py View on Github external
def test_range(self):
        track = otio.schema.Track(name="test_track")
        tl = otio.schema.Timeline("test_timeline", tracks=[track])
        rt = otio.opentime.RationalTime(5, 24)
        mr = otio.schema.ExternalReference(
            available_range=otio.opentime.range_from_start_end_time(
                otio.opentime.RationalTime(5, 24),
                otio.opentime.RationalTime(15, 24)
            ),
            target_url="/var/tmp/test.mov"
        )

        cl = otio.schema.Clip(
            name="test clip1",
            media_reference=mr,
            source_range=otio.opentime.TimeRange(duration=rt),
        )
        cl2 = otio.schema.Clip(
            name="test clip2",
            media_reference=mr,
            source_range=otio.opentime.TimeRange(duration=rt),
github PixarAnimationStudios / OpenTimelineIO / tests / test_timeline.py View on Github external
def test_serialization_of_subclasses(self):
        clip1 = otio.schema.Clip()
        clip1.name = "Test Clip"
        clip1.media_reference = otio.schema.ExternalReference(
            "/tmp/foo.mov"
        )
        tl1 = otio.schema.timeline_from_clips([clip1])
        tl1.name = "Testing Serialization"
        self.assertIsNotNone(tl1)
        otio_module = otio.adapters.from_name("otio_json")
        serialized = otio_module.write_to_string(tl1)
        self.assertIsNotNone(serialized)
        tl2 = otio_module.read_from_string(serialized)
        self.assertIsNotNone(tl2)
        self.assertEqual(type(tl1), type(tl2))
        self.assertEqual(tl1.name, tl2.name)
        self.assertEqual(len(tl1.tracks), 1)
        self.assertEqual(len(tl2.tracks), 1)
        track1 = tl1.tracks[0]
        track2 = tl2.tracks[0]
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / hls_playlist.py View on Github external
def _parse_entries(self, playlist_entries, playlist_version):
        """Interpret the entries through the lens of the schema"""
        current_clip = otio.schema.Clip(
            media_reference=otio.schema.ExternalReference(
                metadata={
                    FORMAT_METADATA_KEY: {},
                    STREAMING_METADATA_KEY: {}
                }
            )
        )
        current_media_ref = current_clip.media_reference
        segment_metadata = {}
        current_map_data = {}
        # per section 4.3.3.2 of Pantos HLS, 0 is default start track
        current_track = 0
        for entry in playlist_entries:
            if entry.type == EntryType.URI:
                # the URI ends the segment definition
                current_media_ref.target_url = entry.uri
                current_media_ref.metadata[FORMAT_METADATA_KEY].update(
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / fcpx_xml.py View on Github external
self._format_frame_rate(
                    asset.get("format", default_format)
                )
            ),
            duration=to_rational_time(
                asset.get("duration"),
                self._format_frame_rate(
                    asset.get("format", default_format)
                )
            )
        )
        asset_clip = self._assetclip_by_ref(asset_id)
        metadata = {}
        if asset_clip:
            metadata = self._create_metadta(asset_clip)
        return otio.schema.ExternalReference(
            target_url=asset.get("src"),
            available_range=available_range,
            metadata={"fcpx": metadata}
        )
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / hls_playlist.py View on Github external
current_media_ref.metadata[FORMAT_METADATA_KEY].update(
                    segment_metadata
                )
                current_media_ref.metadata[STREAMING_METADATA_KEY].update(
                    current_map_data
                )
                current_clip.metadata.setdefault(
                    STREAMING_METADATA_KEY,
                    {}
                )[SEQUENCE_NUM_KEY] = current_track
                self.track.append(current_clip)
                current_track += 1

                # Set up the next segment definition
                current_clip = otio.schema.Clip(
                    media_reference=otio.schema.ExternalReference(
                        metadata={
                            FORMAT_METADATA_KEY: {},
                            STREAMING_METADATA_KEY: {}
                        }
                    )
                )
                current_media_ref = current_clip.media_reference
                continue
            elif entry.type != EntryType.tag:
                # the rest of the code deals only with tags
                continue

            # Explode the EXT-X-MAP info out
            if entry.tag_name == "EXT-X-MAP":
                map_data = self._metadata_dict_for_MAP(entry, playlist_version)
                current_map_data.update(map_data)
github PixarAnimationStudios / OpenTimelineIO / contrib / opentimelineio_contrib / adapters / xges.py View on Github external
show_ignore(
                "Did not find the expected GESUriClip asset with the "
                "id {}".format(asset_id))
            return otio.schema.MissingReference()

        duration = self._get_from_properties(
            asset, "duration", "guint64")

        if duration is None:
            available_range = None
        else:
            available_range = otio.opentime.TimeRange(
                start_time=self.to_rational_time(0),
                duration=self.to_rational_time(duration)
            )
        ref = otio.schema.ExternalReference(
            target_url=asset_id,
            available_range=available_range
        )
        self._add_properties_and_metadatas_to_otio(ref, asset)
        return ref