How to use the opentimelineio.adapters 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_fcp7_xml_adapter.py View on Github external
"""
        )
        context = self.adapter._Context(track_element)

        parser = self.adapter.FCP7XMLParser(transition_element)
        transition = parser.transition_for_element(transition_element, context)

        self.assertEqual(transition.name, "Cross Dissolve")
        self.assertEqual(
            transition.transition_type,
            schema.TransitionTypes.SMPTE_Dissolve,
        )


class AdaptersFcp7XmlTest(unittest.TestCase, test_utils.OTIOAssertions):
    adapter = adapters.from_name('fcp_xml').module()

    def __init__(self, *args, **kwargs):
        super(AdaptersFcp7XmlTest, self).__init__(*args, **kwargs)
        self.maxDiff = None

    def test_build_empty_file(self):
        media_ref = schema.MissingReference(
            name="test_clip_name",
            available_range=opentime.TimeRange(
                opentime.RationalTime(820489, 24),
                opentime.RationalTime(2087, 24),
            ),
            metadata={
                "fcp_xml": {
                    "timecode": {
                        "rate": {"ntsc": "FALSE", "timebase": "24"},
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_track_algo.py View on Github external
def make_sample_track(self):
        return otio.adapters.read_from_string("""
        {
            "OTIO_SCHEMA": "Track.1",
            "children": [
                {
                    "OTIO_SCHEMA": "Clip.1",
                    "effects": [],
                    "markers": [],
                    "media_reference": null,
                    "metadata": {},
                    "name": "A",
                    "source_range": {
                        "OTIO_SCHEMA": "TimeRange.1",
                        "duration": {
                            "OTIO_SCHEMA": "RationalTime.1",
                            "rate": 24,
                            "value": 50
github PixarAnimationStudios / OpenTimelineIO / tests / test_hooks_plugins.py View on Github external
def setUp(self):
        self.man = utils.create_manifest()
        self.jsn = baseline_reader.json_baseline_as_string(HOOKSCRIPT_PATH)
        self.hsf = otio.adapters.otio_json.read_from_string(self.jsn)
        self.hsf._json_path = os.path.join(
            baseline_reader.MODPATH,
            "baselines",
            HOOKSCRIPT_PATH
        )
        self.man.hook_scripts = [self.hsf]

        self.orig_manifest = otio.plugins.manifest._MANIFEST
        otio.plugins.manifest._MANIFEST = self.man
github PixarAnimationStudios / OpenTimelineIO / tests / test_schemadef_plugin.py View on Github external
def test_autoloaded_plugin(self):
        with self.assertRaises(AttributeError):
            otio.schemadef.example_schemadef
        # should force an autoload
        thing = otio.adapters.read_from_string(TEST_STRING, "otio_json")
        self.assertEqual(thing.exampleArg, "foobar")
github PixarAnimationStudios / OpenTimelineIO / src / py-opentimelineio / opentimelineio / console / otioconvert.py View on Github external
if args.begin is not None and args.end is not None:
        result_tl = otio.algorithms.timeline_trimmed_to_range(
            result_tl,
            otio.opentime.range_from_start_end_time(args.begin, args.end)
        )

    try:
        write_adapter_arg_map = otio.console.console_utils.arg_list_to_map(
            args.output_adapter_arg,
            "output adapter"
        )
    except ValueError as exc:
        sys.stderr.write("\n" + str(exc) + "\n")
        sys.exit(1)

    otio.adapters.write_to_file(
        result_tl,
        args.output,
        out_adapter,
        **write_adapter_arg_map
    )
github PixarAnimationStudios / OpenTimelineIO / src / py-opentimelineio / opentimelineio / console / otioconvert.py View on Github external
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the Apache License for the specific
# language governing permissions and limitations under the Apache License.
#

import argparse
import sys
import copy

import opentimelineio as otio

__doc__ = """ Python wrapper around OTIO to convert timeline files between \
formats.

Available adapters: {}
""".format(otio.adapters.available_adapter_names())


def _parsed_args():
    """ parse commandline arguments with argparse """

    parser = argparse.ArgumentParser(
        description=__doc__,
        formatter_class=argparse.ArgumentDefaultsHelpFormatter
    )
    parser.add_argument(
        '-i',
        '--input',
        type=str,
        required=True,
        help='path to input file',
    )
github PixarAnimationStudios / OpenTimelineIO / examples / conform.py View on Github external
def main():
    args = parse_args()

    timeline = otio.adapters.read_from_file(args.input)
    count = _conform_timeline(timeline, args.folder)
    print("Relinked {0} clips to new media.".format(count))
    otio.adapters.write_to_file(timeline, args.output)
    print(
        "Saved {} with {} clips.".format(
            args.output,
            len(list(timeline.each_clip()))
        )