How to use the opentimelineio.adapters.otio_json.read_from_string 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
)

        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)
        self.assertIsOTIOEquivalentTo(cl.media_reference, mr)
        self.assertEqual(cl.source_range, tr)

        encoded = otio.adapters.otio_json.write_to_string(cl)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(cl, decoded)
github PixarAnimationStudios / OpenTimelineIO / tests / test_media_linker.py View on Github external
def setUp(self):
        self.man = utils.create_manifest()
        self.jsn = baseline_reader.json_baseline_as_string(LINKER_PATH)
        self.mln = otio.adapters.otio_json.read_from_string(self.jsn)
        self.mln._json_path = os.path.join(
            baseline_reader.MODPATH,
            "baselines",
            LINKER_PATH
        )
github PixarAnimationStudios / OpenTimelineIO / tests / test_item.py View on Github external
def test_serialize(self):
        tr = otio.opentime.TimeRange(
            otio.opentime.RationalTime(0, 1),
            otio.opentime.RationalTime(10, 1)
        )
        it = otio.core.Item(source_range=tr)
        encoded = otio.adapters.otio_json.write_to_string(it)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(it, decoded)
github PixarAnimationStudios / OpenTimelineIO / tests / test_item.py View on Github external
def test_add_marker(self):
        tr = otio.opentime.TimeRange(
            duration=otio.opentime.RationalTime(10, 1)
        )
        it = otio.core.Item(source_range=tr)
        it.markers.append(
            otio.schema.Marker(
                name="test_marker",
                marked_range=tr,
                metadata={
                    'some stuff to mark': '100'
                }
            )
        )
        encoded = otio.adapters.otio_json.write_to_string(it)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(it, decoded)
        self.assertJsonEqual(it.markers, decoded.markers)
github PixarAnimationStudios / OpenTimelineIO / tests / test_serializable_object.py View on Github external
def test_serialize_time(self):
        rt = otio.opentime.RationalTime(15, 24)
        encoded = otio.adapters.otio_json.write_to_string(rt)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertEqual(rt, decoded)

        rt_dur = otio.opentime.RationalTime(10, 20)
        tr = otio.opentime.TimeRange(rt, rt_dur)
        encoded = otio.adapters.otio_json.write_to_string(tr)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertEqual(tr, decoded)

        tt = otio.opentime.TimeTransform(rt, scale=1.5)
        encoded = otio.adapters.otio_json.write_to_string(tt)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertEqual(tt, decoded)
github PixarAnimationStudios / OpenTimelineIO / tests / test_serializable_object.py View on Github external
def test_serialize_time(self):
        rt = otio.opentime.RationalTime(15, 24)
        encoded = otio.adapters.otio_json.write_to_string(rt)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertEqual(rt, decoded)

        rt_dur = otio.opentime.RationalTime(10, 20)
        tr = otio.opentime.TimeRange(rt, rt_dur)
        encoded = otio.adapters.otio_json.write_to_string(tr)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertEqual(tr, decoded)

        tt = otio.opentime.TimeTransform(rt, scale=1.5)
        encoded = otio.adapters.otio_json.write_to_string(tt)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertEqual(tt, decoded)
github PixarAnimationStudios / OpenTimelineIO / tests / test_json_backend.py View on Github external
def check_against_baseline(self, obj, testname):
        baseline = baseline_reader.json_baseline(testname)

        self.assertDictEqual(
            baseline_reader.json_from_string(
                otio.adapters.otio_json.write_to_string(obj)
            ),
            baseline
        )
        baseline_data = otio.adapters.otio_json.read_from_string(
            json.dumps(baseline)
        )
        if isinstance(baseline_data, dict):
            raise TypeError("did not deserialize correctly")

        self.assertJsonEqual(obj, baseline_data)
github PixarAnimationStudios / OpenTimelineIO / tests / test_marker.py View on Github external
otio.opentime.RationalTime(5, 24),
            otio.opentime.RationalTime(10, 24)
        )
        m = otio.schema.Marker(
            name="marker_1",
            marked_range=tr,
            color=otio.schema.MarkerColor.GREEN,
            metadata={'foo': 'bar'}
        )
        self.assertEqual(m.name, 'marker_1')
        self.assertEqual(m.metadata['foo'], 'bar')
        self.assertEqual(m.marked_range, tr)
        self.assertEqual(m.color, otio.schema.MarkerColor.GREEN)

        encoded = otio.adapters.otio_json.write_to_string(m)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(m, decoded)
github PixarAnimationStudios / OpenTimelineIO / tests / test_transition.py View on Github external
def test_serialize(self):
        trx = otio.schema.Transition(
            name="AtoB",
            transition_type="SMPTE.Dissolve",
            metadata={
                "foo": "bar"
            }
        )
        encoded = otio.adapters.otio_json.write_to_string(trx)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(trx, decoded)