opentimelineio package

An editorial interchange format and library.

see: http://opentimeline.io

Subpackages

Submodules

opentimelineio.exceptions module

Exception classes for OpenTimelineIO

exception opentimelineio.exceptions.AdapterDoesntSupportFunctionError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.CannotTrimTransitionsError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.CouldNotReadFileError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.InstancingNotAllowedError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.InvalidSerializableLabelError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.MisconfiguredPluginError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.NoDefaultMediaLinkerError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.NoKnownAdapterForExtensionError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.NotSupportedError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.ReadingNotSupportedError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.TransitionFollowingATransitionError

Bases: opentimelineio._otio.OTIOError

exception opentimelineio.exceptions.WritingNotSupportedError

Bases: opentimelineio._otio.OTIOError

opentimelineio.hooks module

HookScripts are plugins that run at defined points (“Hooks”).

They expose a hook_function with signature: hook_function :: otio.schema.Timeline, Dict -> otio.schema.Timeline

Both hook scripts and the hooks they attach to are defined in the plugin manifest.

You can attach multiple hook scripts to a hook. They will be executed in list order, first to last.

They are defined by the manifests HookScripts and hooks areas.

>>>
{
    "OTIO_SCHEMA" : "PluginManifest.1",
    "hook_scripts" : [
        {
            "OTIO_SCHEMA" : "HookScript.1",
            "name" : "example hook",
            "execution_scope" : "in process",
            "filepath" : "example.py"
        }
    ],
    "hooks" : {
        "pre_adapter_write" : ["example hook"],
        "post_adapter_read" : []
    }
}

The ‘hook_scripts’ area loads the python modules with the ‘hook_function’s to call in them. The ‘hooks’ area defines the hooks (and any associated scripts). You can further query and modify these from python.

>>> import opentimelineio as otio
... hook_list = otio.hooks.scripts_attached_to("some_hook") # -> ['a','b','c']
...
... # to run the hook scripts:
... otio.hooks.run("some_hook", some_timeline, optional_argument_dict)

This will pass (some_timeline, optional_argument_dict) to ‘a’, which will a new timeline that will get passed into ‘b’ with optional_argument_dict, etc.

To Edit the order, change the order in the list:

>>> hook_list[0], hook_list[2] = hook_list[2], hook_list[0]
... print hook_list # ['c','b','a']

Now c will run, then b, then a.

To delete a function the list:

>>> del hook_list[1]
class opentimelineio.hooks.HookScript(*args, **kwargs)

Bases: opentimelineio.plugins.python_plugin.PythonPlugin

run(in_timeline, argument_map={})

Run the hook_function associated with this plugin.

opentimelineio.hooks.available_hookscript_names()

Return the names of HookScripts that have been registered.

opentimelineio.hooks.available_hookscripts()

Return the HookScripts objects that have been registered.

opentimelineio.hooks.names()

Return a list of all the registered hooks.

opentimelineio.hooks.run(hook, tl, extra_args=None)

Run all the scripts associated with hook, passing in tl and extra_args.

Will return the return value of the last hook script.

If no hookscripts are defined, returns tl.

opentimelineio.hooks.scripts_attached_to(hook)

Return an editable list of all the hook scriptss that are attached to the specified hook, in execution order. Changing this list will change the order that scripts run in, and deleting a script will remove it from executing

opentimelineio.media_linker module

MediaLinker plugins fire after an adapter has read a file in order to produce MediaReferences that point at valid, site specific media.

They expose a “link_media_reference” function with the signature: link_media_reference :: otio.schema.Clip -> otio.core.MediaReference

or:
def linked_media_reference(from_clip):

result = otio.core.MediaReference() # whichever subclass # do stuff return result

To get context information, they can inspect the metadata on the clip and on the media reference. The .parent() method can be used to find the containing track if metadata is stored there.

Please raise an instance (or child instance) of otio.exceptions.CannotLinkMediaError() if there is a problem linking the media.

For example:
for clip in timeline.each_clip():
try:

new_mr = otio.media_linker.linked_media_reference(clip) clip.media_reference = new_mr

except otio.exceptions.CannotLinkMediaError:

# or report the error pass

class opentimelineio.media_linker.MediaLinker(*args, **kwargs)

Bases: opentimelineio.plugins.python_plugin.PythonPlugin

is_default_linker()
plugin_info_map()

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

class opentimelineio.media_linker.MediaLinkingPolicy

Bases: object

DoNotLinkMedia = '__do_not_link_media'
ForceDefaultLinker = '__default'
opentimelineio.media_linker.available_media_linker_names()

Return a string list of the available media linker plugins.

opentimelineio.media_linker.default_media_linker()
opentimelineio.media_linker.from_name(name)

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

opentimelineio.media_linker.linked_media_reference(target_clip, media_linker_name='__default', media_linker_argument_map=None)

opentimelineio.opentime module

opentimelineio.opentime.to_frames(rt, rate=None)
opentimelineio.opentime.to_seconds(rt)
opentimelineio.opentime.to_time_string(rt)
opentimelineio.opentime.to_timecode(rt, rate=None, drop_frame=None)

opentimelineio.test_utils module

Utility assertions for OTIO Unit tests.

class opentimelineio.test_utils.OTIOAssertions

Bases: object

assertIsOTIOEquivalentTo(known, test_result)

Test using the ‘is equivalent to’ method on SerializableObject

assertJsonEqual(known, test_result)

Convert to json and compare that (more readable).