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 asTrack
orStack
).- parent() opentimelineio._otio.Composition ¶
- 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 containsComposable
s.Should be subclassed (for example by
Track
andStack
), 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 ¶
- insert(index, item)¶
- is_parent_of(other: opentimelineio._otio.Composable) bool ¶
- 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.
- 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¶
- 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 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¶
- 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
- 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
- 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.
flatten_stack(in_stack: opentimelineio._otio.Stack) -> opentimelineio._otio.Track
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, …}}
- 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.
- 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
- 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
- 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.
- 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
cls (Type[SerializableObject]) – class to upgrade
version_to_upgrade_to (int) – the version to upgrade to
Modules