opentimelineio.core

Core implementation details and wrappers around the C++ library

class opentimelineio.core.Composable(name: str = '', metadata: object = 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: Optional[List[opentimelineio._otio.Composable]] = None, source_range: Optional[opentimelineio._opentime.TimeRange] = None, metadata: object = None)

Base class for an Item that contains Composables.

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_in_range(search_range: opentimelineio._opentime.TimeRange) List[opentimelineio._otio.SerializableObject]
property composition_kind
find_children(descended_from_type: object = None, search_range: Optional[opentimelineio._opentime.TimeRange] = None, shallow_search: bool = False) List[opentimelineio._otio.SerializableObject]
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: Optional[List[opentimelineio._otio.Effect]] = None, markers: Optional[List[opentimelineio._otio.Marker]] = None, enabled: bool = True, metadata: object = 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)
property available_image_bounds
property available_range
property is_missing_reference
class opentimelineio.core.SerializableObject

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)
property metadata
property name
class opentimelineio.core.Track(name: str = '', children: Optional[List[opentimelineio._otio.Composable]] = None, source_range: Optional[opentimelineio._opentime.TimeRange] = None, kind: str = 'Video', metadata: object = None)
class Kind
Audio = 'Audio'
Video = 'Video'
class NeighborGapPolicy(value: int)

Members:

around_transitions

never

around_transitions = <NeighborGapPolicy.around_transitions: 1>
property name
never = <NeighborGapPolicy.never: 0>
property value
find_clips(search_range: Optional[opentimelineio._opentime.TimeRange] = None, shallow_search: bool = False) List[opentimelineio._otio.SerializableObject]
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: List[opentimelineio._otio.Track]) opentimelineio._otio.Track

Overloaded function.

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

  2. flatten_stack(tracks: List[opentimelineio._otio.Track]) -> 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, default_value=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

  • default_value (Any) – default value to return if no field value is set yet

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