How to use the opentimelineio.adapters.otio_json.write_to_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_composition.py View on Github external
def test_serialize(self):
        st = otio.schema.Stack(
            name="test",
            children=[otio.schema.Clip(name="testClip")]
        )

        encoded = otio.adapters.otio_json.write_to_string(st)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(st, decoded)

        self.assertIsNotNone(decoded[0].parent())
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)
github PixarAnimationStudios / OpenTimelineIO / tests / test_timeline.py View on Github external
def test_metadata(self):
        rt = otio.opentime.RationalTime(12, 24)
        tl = otio.schema.Timeline("test_timeline", global_start_time=rt)
        tl.metadata['foo'] = "bar"
        self.assertEqual(tl.metadata['foo'], 'bar')

        encoded = otio.adapters.otio_json.write_to_string(tl)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(tl, decoded)
        self.assertEqual(tl.metadata, decoded.metadata)
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_serializable_collection.py View on Github external
def test_serialize(self):
        encoded = otio.adapters.otio_json.write_to_string(self.sc)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(self.sc, decoded)
github PixarAnimationStudios / OpenTimelineIO / tests / test_generator_reference.py View on Github external
def test_serialize(self):
        encoded = otio.adapters.otio_json.write_to_string(self.gen)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(self.gen, decoded)
github PixarAnimationStudios / OpenTimelineIO / tests / test_timeline.py View on Github external
def test_serialize_timeline(self):
        clip = otio.schema.Clip(
            name="test_clip",
            media_reference=otio.schema.MissingReference()
        )
        tl = otio.schema.timeline_from_clips([clip])
        encoded = otio.adapters.otio_json.write_to_string(tl)
        decoded = otio.adapters.otio_json.read_from_string(encoded)
        self.assertIsOTIOEquivalentTo(tl, decoded)

        string2 = otio.adapters.otio_json.write_to_string(decoded)
        self.assertEqual(encoded, string2)
github PixarAnimationStudios / OpenTimelineIO / src / py-opentimelineio / opentimelineio / console / autogen_serialized_datamodel.py View on Github external
or thing in (
                otio.opentime.RationalTime,
                otio.opentime.TimeRange,
                otio.opentime.TimeTransform,
            )
        )
    ]

    # serialize/deserialize the classes to capture their serialized parameters
    model = {}
    for cl in serializeable_classes:
        if cl in SKIP_CLASSES:
            continue

        model[cl] = {}
        field_dict = json.loads(otio.adapters.otio_json.write_to_string(cl()))
        for k in field_dict.keys():
            if k in SKIP_KEYS:
                continue

            for fetcher in PROP_FETCHERS:
                try:
                    model[cl][k] = fetcher(cl, k)
                    break
                except AttributeError:
                    pass
            else:
                sys.stderr.write("ERROR: could not fetch property: {}".format(k))

        # Stashing the OTIO_SCHEMA back into the dictionary since the
        # documentation uses this information in its header.
        model[cl]["OTIO_SCHEMA"] = field_dict["OTIO_SCHEMA"]