opentimelineio.adapters package

Expose the adapter interface to developers.

To read from an existing representation, use the read_from_string and read_from_file functions. To query the list of adapters, use the available_adapter_names function.

The otio_json adapter is provided as a the canonical, lossless, serialization of the in-memory otio schema. Other adapters are to varying degrees lossy. For more information, consult the documentation in the individual adapter modules.


Return a string list of the available adapters.


Guess the adapter object to use for a given filepath.


“foo.otio” returns the “otio_json” adapter.


Fetch the adapter object by the name of the adapter directly.

opentimelineio.adapters.read_from_file(filepath, adapter_name=None, media_linker_name='__default', media_linker_argument_map=None, **adapter_argument_map)

Read filepath using adapter_name.

If adapter_name is None, try and infer the adapter name from the filepath.

For example:

timeline = read_from_file(“example_trailer.otio”) timeline = read_from_file(“file_with_no_extension”, “cmx_3600”)

opentimelineio.adapters.read_from_string(input_str, adapter_name='otio_json', media_linker_name='__default', media_linker_argument_map=None, **adapter_argument_map)

Read a timeline from input_str using adapter_name.

This is useful if you obtain a timeline from someplace other than the filesystem.


raw_text = urlopen(my_url).read() timeline = read_from_string(raw_text, “otio_json”)

opentimelineio.adapters.suffixes_with_defined_adapters(read=False, write=False)

Return a set of all the suffixes that have adapters defined for them.

opentimelineio.adapters.write_to_file(input_otio, filepath, adapter_name=None, **adapter_argument_map)

Write input_otio to filepath using adapter_name.

If adapter_name is None, infer the adapter_name to use based on the filepath.


otio.adapters.write_to_file(my_timeline, “output.otio”)

opentimelineio.adapters.write_to_string(input_otio, adapter_name='otio_json', **adapter_argument_map)

Return input_otio written to a string using adapter_name.


raw_text = otio.adapters.write_to_string(my_timeline, “otio_json”)


opentimelineio.adapters.adapter module

Implementation of the OTIO internal Adapter system.

For information on writing adapters, please consult: # noqa

class opentimelineio.adapters.adapter.Adapter(*args, **kwargs)

Bases: opentimelineio.plugins.python_plugin.PythonPlugin

Adapters convert between OTIO and other formats.

Note that this class is not subclassed by adapters. Rather, an adapter is a python module that implements at least one of the following functions:

write_to_string(input_otio) write_to_file(input_otio, filepath) (optionally inferred) read_from_string(input_str) read_from_file(filepath) (optionally inferred)

…as well as a small json file that advertises the features of the adapter to OTIO. This class serves as the wrapper around these modules internal to OTIO. You should not need to extend this class to create new adapters for OTIO.

For more information: # noqa


return true if adapter supports feature_string, which must be a key of the _FEATURE_MAP dictionary.

Will trigger a call to self.module(), which imports the plugin.


Adds extra adapter-specific information to call to the parent fn.

read_from_file(filepath, media_linker_name='__default', media_linker_argument_map=None, hook_function_argument_map={}, **adapter_argument_map)

Execute the read_from_file function on this adapter.

If read_from_string exists, but not read_from_file, execute that with a trivial file object wrapper.

read_from_string(input_str, media_linker_name='__default', media_linker_argument_map=None, hook_function_argument_map={}, **adapter_argument_map)

Call the read_from_string function on this adapter.

property suffixes

File suffixes associated with this adapter.

write_to_file(input_otio, filepath, hook_function_argument_map={}, **adapter_argument_map)

Execute the write_to_file function on this adapter.

If write_to_string exists, but not write_to_file, execute that with a trivial file object wrapper.

write_to_string(input_otio, hook_function_argument_map={}, **adapter_argument_map)

Call the write_to_string function on this adapter.

opentimelineio.adapters.cmx_3600 module

OpenTimelineIO CMX 3600 EDL Adapter

class opentimelineio.adapters.cmx_3600.ClipHandler(line, comment_data, rate=24)

Bases: object

class opentimelineio.adapters.cmx_3600.CommentHandler(comments)

Bases: object

comment_id_map = {'ASC_SAT': 'asc_sat', 'ASC_SOP': 'asc_sop', 'FROM CLIP': 'media_reference', 'FROM CLIP NAME': 'clip_name', 'FROM FILE': 'media_reference', 'LOC': 'locators', 'M2': 'motion_effect', 'TO CLIP NAME': 'dest_clip_name', '\\* FREEZE FRAME': 'freeze_frame'}
regex_template = '\\*?\\s*{id}:?\\s*(?P<comment_body>.*)'
class opentimelineio.adapters.cmx_3600.DissolveEvent(a_side_event, transition, b_side_clip, tracks, kind, rate, style, reelname_len)

Bases: object


Example output:

Cross dissolve… 002 Clip1 V C 00:00:07:08 00:00:07:08 00:00:01:21 00:00:01:21 002 Clip2 V D 100 00:00:09:07 00:00:17:15 00:00:01:21 00:00:10:05 * FROM CLIP NAME: Clip1 * FROM CLIP: /var/tmp/clip1.001.exr * TO CLIP NAME: Clip2 * TO CLIP: /var/tmp/clip2.001.exr

Fade in… 001 BL V C 00:00:00:00 00:00:00:00 00:00:00:00 00:00:00:00 001 My_Clip V D 012 00:00:02:02 00:00:03:04 00:00:00:00 00:00:01:02 * TO CLIP NAME: My Clip * TO FILE: /var/tmp/clip.001.exr

Fade out… 002 My_Clip V C 00:00:01:12 00:00:01:12 00:00:00:12 00:00:00:12 002 BL V D 012 00:00:00:00 00:00:00:12 00:00:00:12 00:00:01:00 * FROM CLIP NAME: My Clip * FROM FILE: /var/tmp/clip.001.exr

exception opentimelineio.adapters.cmx_3600.EDLParseError

Bases: opentimelineio._otio.OTIOError

class opentimelineio.adapters.cmx_3600.EDLParser(edl_string, rate=24, ignore_timecode_mismatch=False)

Bases: object

add_clip(line, comments, rate=24)
add_transition(clip_handler, transition, data)
parse_edl(edl_string, rate=24)
class opentimelineio.adapters.cmx_3600.EDLWriter(tracks, rate, style, reelname_len=8)

Bases: object

get_content_for_track_at_index(idx, title)
class opentimelineio.adapters.cmx_3600.Event(clip, tracks, kind, rate, style, reelname_len)

Bases: object

Example output:

002 AX V C 00:00:00:00 00:00:00:05 00:00:00:05 00:00:00:10 * FROM CLIP NAME: test clip2 * FROM FILE: S:vartmptest.exr

class opentimelineio.adapters.cmx_3600.EventLine(kind, rate, reel='AX')

Bases: object

opentimelineio.adapters.cmx_3600.read_from_string(input_str, rate=24, ignore_timecode_mismatch=False)

Reads a CMX Edit Decision List (EDL) from a string. Since EDLs don’t contain metadata specifying the rate they are meant for, you may need to specify the rate parameter (default is 24). By default, read_from_string will throw an exception if it discovers invalid timecode in the EDL. For example, if a clip’s record timecode overlaps with the previous cut. Since this is a common mistake in many EDLs, you can specify ignore_timecode_mismatch=True, which will supress these errors and attempt to guess at the correct record timecode based on the source timecode and adjacent cuts. For best results, you may wish to do something like this:

>>> try:
...     timeline = otio.adapters.read_from_string("mymovie.edl", rate=30)
... except EDLParseError:
...    print('Log a warning here')
...    try:
...        timeline = otio.adapters.read_from_string(
...            "mymovie.edl",
...            rate=30,
...            ignore_timecode_mismatch=True)
...    except EDLParseError:
...        print('Log an error here')
opentimelineio.adapters.cmx_3600.write_to_string(input_otio, rate=None, style='avid', reelname_len=8)

opentimelineio.adapters.fcp_xml module

OpenTimelineIO Final Cut Pro 7 XML Adapter.

class opentimelineio.adapters.fcp_xml.FCP7XMLParser(element_tree)

Bases: object

Implements parsing of an FCP XML file into an OTIO timeline.

Parsing FCP XML elements include two concepts that require carrying state:
  1. Inheritance

  2. The id Attribute

See also AppleApplications/Reference/FinalCutPro_XML/Basics/Basics.html #//apple_ref/doc/uid/TP30001154-TPXREF102

Inheritance is implemented using a _Context object that is pushed down through layers of parsing. A given parsing method is passed the element to parse into an otio object along with the context that element exists under (e.x. a track element parsing method is given the track element and the sequence context for that track).

The id attribute dereferencing is handled through a lookup table stored on parser instances and using the _derefed_ methods to take an element and find dereference elements.

clip_for_element(clipitem_element, item_range, start_offset, context)

Given a clipitem xml element, returns an :class: schema.Clip.

  • clipitem_element – The element to create a clip for.

  • item_range – The time range in the timeline the clip occupies.

  • start_offset – The amount by which the in time of the clip source should be advanced (usually due to a transition).

  • context – The parent context for the clip.


The :class: schema.Clip instance.


Given a filter element, creates an :class: schema.Effect.


filter_element – The filter element containing the effect.


The effect instance.

item_and_timing_for_element(item_element, head_transition, tail_transition, context)

Given a track item, returns a tuple with the appropriate OpenTimelineIO schema item as the first element and an :class: opentime.TimeRange of the resolved timeline range the clip occupies.

  • item_element – The track item XML node.

  • head_transition – The xml element for the transition immediately before or None.

  • tail_transition – The xml element for the transition immediately after or None.

  • context – The context dictionary.


An :class: core.Item subclass instance and :class: opentime.TimeRange for the item.


Given an effect element, returns a generator reference.


effect_element – The effect for the generator.


An :class: schema.GeneratorReference instance.

media_reference_for_file_element(file_element, context)

Given a file XML element, returns the :class`schema.ExternalReference`.

  • file_element – The file xml element.

  • context – The parent context dictionary.


An :class: schema.ExternalReference.

stack_for_element(element, context)

Given an element, parses out track information as a stack.

  • element – The element under which to find the tracks (typically a media element.

  • context – The current parser context.


A :class: schema.Stack of the tracks.

timeline_for_sequence(sequence_element, context)

Returns either an :class`schema.Timeline` parsed from a sequence element.

  • sequence_element – The sequence element.

  • context – The context dictionary.


The appropriate OTIO object for the element.


” Returns a list of timelines for the top-level sequences in the file.

track_for_element(track_element, track_kind, context)

Given a track element, constructs the OTIO track.

  • track_element – The track XML element.

  • track_kind – The :class: schema.TrackKind for the track.

  • context – The context dict for this track.

transition_for_element(item_element, context)

Creates an OTIO transition for the provided transition element.

  • item_element – The element to create a transition for.

  • context – The parent context for the element.


The :class: schema.Transition instance.

opentimelineio.adapters.fcp_xml.marker_for_element(marker_element, rate)

Creates an :class: schema.Marker for the provided element.

  • marker_element – The XML element for the marker.

  • rate – The rate for the object the marker is attached to.


The :class: schema.Marker instance.

opentimelineio.adapters.fcp_xml.markers_from_element(element, context=None)

Given an element, returns the list of markers attached to it.

  • element – An element with one or more marker child elements.

  • context – The context for this element.


A :class: list of :class: schema.Marker instances attached to the provided element.


opentimelineio.adapters.otio_json module

This adapter lets you read and write native .otio files


De-serializes an OpenTimelineIO object from a file


filepath (str): The path to an otio file to read from


OpenTimeline: An OpenTimeline object


De-serializes an OpenTimelineIO object from a json string


input_str (str): A string containing json serialized otio contents


OpenTimeline: An OpenTimeline object

opentimelineio.adapters.otio_json.write_to_file(input_otio, filepath, indent=4)

Serializes an OpenTimelineIO object into a file


input_otio (OpenTimeline): An OpenTimeline object filepath (str): The name of an otio file to write to indent (int): number of spaces for each json indentation level. Use -1 for no indentation or newlines.


bool: Write success


ValueError: on write error

opentimelineio.adapters.otio_json.write_to_string(input_otio, indent=4)

Serializes an OpenTimelineIO object into a string


input_otio (OpenTimeline): An OpenTimeline object indent (int): number of spaces for each json indentation level. Use -1 for no indentation or newlines.


str: A json serialized string representation