opentimelineio.core

Core implementation details and wrappers around the C++ library

class opentimelineio.core.Composable(name: str = '', metadata: object = None) None

An object that can be composed within a Composition (such as Track or Stack).

overlapping() bool
parent() opentimelineio._otio.Composition
visible() bool
class opentimelineio.core.Composition(name: str = '', children: object = None, source_range: Optional[opentimelineio._opentime.TimeRange] = None, metadata: object = None) None

Base class for an Item that contains other Items.

Should be subclassed (for example by Track and Stack), not used directly.

child_at_time(search_time: opentimelineio._opentime.RationalTime, shallow_search: bool = False) opentimelineio._otio.Composable
children_if(descended_from_type: object = None, search_range: Optional[opentimelineio._opentime.TimeRange] = None, shallow_search: bool = False) List[opentimelineio._otio.SerializableObject]
children_in_range(search_range: opentimelineio._opentime.TimeRange) List[opentimelineio._otio.SerializableObject]
property composition_kind
each_child(search_range=None, descended_from_type=<class 'opentimelineio._otio.Composable'>, shallow_search=False)

Generator that returns each child contained in the composition in the order in which it is found.

Deprecated since version 0.14.0: Use children_if() instead.

Parameters
  • search_range (TimeRange) – if specified, only children whose range overlaps with the search range will be yielded.

  • descended_from_type (type) – if specified, only children who are a descendent of the descended_from_type will be yielded.

  • shallow_search (bool) – if True, will only search children of self, not and not recurse into children of children.

handles_of_child(child: opentimelineio._otio.Composable) tuple
has_clips() bool
insert(index, item)
is_parent_of(other: opentimelineio._otio.Composable) bool
range_of_all_children() dict
range_of_child(child: opentimelineio._otio.Composable, reference_space: opentimelineio._otio.Composable = None) opentimelineio._opentime.TimeRange
range_of_child_at_index(index: int) opentimelineio._opentime.TimeRange
trim_child_range(child_range: opentimelineio._opentime.TimeRange) Optional[opentimelineio._opentime.TimeRange]
trimmed_child_range(child_range: opentimelineio._opentime.TimeRange) Optional[opentimelineio._opentime.TimeRange]
trimmed_range_of_child(child: opentimelineio._otio.Composable, reference_space: opentimelineio._otio.Composable = None) Optional[opentimelineio._opentime.TimeRange]
trimmed_range_of_child_at_index(index: int) opentimelineio._opentime.TimeRange
class opentimelineio.core.Item(name: str = '', source_range: Optional[opentimelineio._opentime.TimeRange] = None, effects: object = None, markers: object = None, enabled: bool = True, metadata: object = None) None
property available_image_bounds
available_range() opentimelineio._opentime.TimeRange
duration() opentimelineio._opentime.RationalTime
property effects
property enabled

If true, an Item contributes to compositions. For example, when an audio/video clip is enabled=false the clip is muted/hidden.

property markers
range_in_parent() opentimelineio._opentime.TimeRange
property source_range
transformed_time(time: opentimelineio._opentime.RationalTime, to_item: opentimelineio._otio.Item) opentimelineio._opentime.RationalTime
transformed_time_range(time_range: opentimelineio._opentime.TimeRange, to_item: opentimelineio._otio.Item) opentimelineio._opentime.TimeRange
trimmed_range() opentimelineio._opentime.TimeRange
trimmed_range_in_parent() Optional[opentimelineio._opentime.TimeRange]
visible_range() opentimelineio._opentime.TimeRange
class opentimelineio.core.MediaReference(name: str = '', available_range: Optional[opentimelineio._opentime.TimeRange] = None, metadata: object = None, available_image_bounds: Optional[opentimelineio._otio.Box2d] = None) None
property available_image_bounds
property available_range
property is_missing_reference
class opentimelineio.core.SerializableObject None

Superclass for all classes whose instances can be serialized.

clone() opentimelineio._otio.SerializableObject
deepcopy(*args, **kwargs)
static from_json_file(file_name: str) opentimelineio._otio.SerializableObject
static from_json_string(input: str) opentimelineio._otio.SerializableObject
is_equivalent_to(other: opentimelineio._otio.SerializableObject) bool
property is_unknown_schema
schema_name() str
schema_version() int
to_json_file(file_name: str, indent: int = 4) bool
to_json_string(indent: int = 4) str
class opentimelineio.core.SerializableObjectWithMetadata(name: str = '', metadata: object = None) None
property metadata
property name
class opentimelineio.core.Track(name: object = '', children: object = None, source_range: Optional[opentimelineio._opentime.TimeRange] = None, kind: str = 'Video', metadata: object = None) None
class Kind
Audio = 'Audio'
Video = 'Video'
class NeighborGapPolicy(value: int) None

Members:

around_transitions

never

around_transitions = <NeighborGapPolicy.around_transitions: 1>
property name
never = <NeighborGapPolicy.never: 0>
property value
clip_if(search_range: Optional[opentimelineio._opentime.TimeRange] = None, shallow_search: bool = False) List[opentimelineio._otio.SerializableObject]
each_clip(search_range=None, shallow_search=False)

Generator that returns each clip contained in the track in the order in which it is found.

Deprecated since version 0.14.0: Use clip_if() instead.

Parameters
  • search_range (TimeRange) – if specified, only children whose range overlaps with the search range will be yielded.

  • shallow_search (bool) – if True, will only search children of self and not recurse into children of children.

property kind
neighbors_of(item: opentimelineio._otio.Composable, policy: opentimelineio._otio.Track.NeighborGapPolicy = <NeighborGapPolicy.never: 0>) tuple
opentimelineio.core.add_method(cls)
opentimelineio.core.deprecated_field()

For marking attributes on a SerializableObject deprecated.

opentimelineio.core.deserialize_json_from_file(filename: str) object

Deserialize json file to in-memory objects.

Parameters

filename (str) – path to json file to read

Returns

root object in the file (usually a Timeline or SerializableCollection)

Return type

SerializableObject

opentimelineio.core.deserialize_json_from_string(input: str) object

Deserialize json string to in-memory objects.

Parameters

input (str) – json string to deserialize

Returns

root object in the string (usually a Timeline or SerializableCollection)

Return type

SerializableObject

opentimelineio.core.downgrade_function_from(cls, version_to_downgrade_from)

Decorator for identifying schema class downgrade functions.

Example:

@downgrade_function_from(MyClass, 5)
def downgrade_from_five_to_four(data):
    return {"old_attr": data["new_attr"]}

This will get called to downgrade a schema of MyClass from version 5 to version 4. MyClass must be a class deriving from SerializableObject.

The downgrade function should take a single argument - the dictionary to downgrade, and return a dictionary with the fields downgraded.

Parameters
  • cls (Type[SerializableObject]) – class to downgrade

  • version_to_downgrade_from (int) – the function downgrading from this version to (version - 1)

opentimelineio.core.flatten_stack(in_stack: opentimelineio._otio.Stack) opentimelineio._otio.Track
opentimelineio.core.flatten_stack(tracks: object) opentimelineio._otio.Track

Overloaded function.

  1. flatten_stack(in_stack: opentimelineio._otio.Stack) -> opentimelineio._otio.Track

  2. flatten_stack(tracks: object) -> opentimelineio._otio.Track

opentimelineio.core.install_external_keepalive_monitor(so: opentimelineio._otio.SerializableObject, apply_now: bool) None
opentimelineio.core.instance_from_schema(schema_name: str, schema_version: int, data: object) opentimelineio._otio.SerializableObject

Return an instance of the schema from data in the data_dict.

Raises

UnsupportedSchemaError – when the requested schema version is greater than the registered schema version.

opentimelineio.core.register_type(classobj, schemaname=None)

Decorator for registering a SerializableObject type

Example:

@otio.core.register_type
class SimpleClass(otio.core.SerializableObject):
  serializable_label = "SimpleClass.2"
  ...
Parameters
  • cls (Type[SerializableObject]) – class to register

  • schemaname (str) – Schema name (default: parse from serializable_label)

opentimelineio.core.release_to_schema_version_map() Dict[str, Dict[str, int]]

Fetch the compiled in CORE_VERSION_MAP.

The CORE_VERSION_MAP maps OTIO release versions to maps of schema name to schema version and is autogenerated by the OpenTimelineIO build and release system. For example: {“0.15.0”: {“Clip”: 2, …}}

Returns

dictionary mapping core version label to schema_version_map

Return type

dict[str, dict[str, int]]

opentimelineio.core.serializable_field(name, required_type=None, doc=None)

Convenience function for adding attributes to child classes of SerializableObject in such a way that they will be serialized/deserialized automatically.

Use it like this:

@core.register_type
class Foo(SerializableObject):
    bar = serializable_field("bar", required_type=int, doc="example")

This would indicate that class “foo” has a serializable field “bar”. So:

f = foo()
f.bar = "stuff"

# serialize & deserialize
otio_json = otio.adapters.from_name("otio")
f2 = otio_json.read_from_string(otio_json.write_to_string(f))

# fields should be equal
f.bar == f2.bar

Additionally, the “doc” field will become the documentation for the property.

Parameters
  • name (str) – name of the field to add

  • required_type (type) – type required for the field

  • doc (str) – field documentation

Returns

property object

Return type

property

opentimelineio.core.serialize_json_to_file(root, filename, schema_version_targets=None, indent=4)

Serialize root to a json file. Optionally downgrade resulting schemas to schema_version_targets.

Parameters
  • root (SerializableObject) – root object to serialize

  • schema_version_targets (dict[str, int]) – optional dictionary mapping schema name to desired schema version, for downgrading the result to be compatible with older versions of OpenTimelineIO.

  • indent (int) – number of spaces for each json indentation level. Use -1 for no indentation or newlines.

Returns

true for success, false for failure

Return type

bool

opentimelineio.core.serialize_json_to_string(root, schema_version_targets=None, indent=4)

Serialize root to a json string. Optionally downgrade resulting schemas to schema_version_targets.

Parameters
  • root (SerializableObject) – root object to serialize

  • schema_version_targets (dict[str, int]) – optional dictionary mapping schema name to desired schema version, for downgrading the result to be compatible with older versions of OpenTimelineIO.

  • indent (int) – number of spaces for each json indentation level. Use -1 for no indentation or newlines.

Returns

resulting json string

Return type

str

opentimelineio.core.set_type_record(serializable_obejct: opentimelineio._otio.SerializableObject, schema_name: str) None
opentimelineio.core.type_version_map() Dict[str, int]

Fetch the currently registered schemas and their versions.

Returns

Map of all registered schema names to their current versions.

Return type

dict[str, int]

opentimelineio.core.upgrade_function_for(cls, version_to_upgrade_to)

Decorator for identifying schema class upgrade functions.

Example:

@upgrade_function_for(MyClass, 5)
def upgrade_to_version_five(data):
    pass

This will get called to upgrade a schema of MyClass to version 5. MyClass must be a class deriving from SerializableObject.

The upgrade function should take a single argument - the dictionary to upgrade, and return a dictionary with the fields upgraded.

Remember that you don’t need to provide an upgrade function for upgrades that add or remove fields, only for schema versions that change the field names.

Parameters

Modules

opentimelineio.core.composable

opentimelineio.core.composition

opentimelineio.core.item

opentimelineio.core.mediaReference