An .otio file is JSON holding a tree of nested objects. The project publishes
a draft specification of the file as of OTIO Beta 13, an autogenerated list of the
serialised types and the source code of its library. The specification recommends using
the library rather than writing a new reader or writer.
JSON rules
- Use the extension
.otio;.jsonis discouraged. - Integers are signed 64-bit values and floating-point numbers are IEEE 754 doubles.
- Beyond standard JSON, doubles may be
NaN,InforInfinity, and-Infor-Infinity. Such a file is not valid strict JSON. - The library writes keys in a predictable order, to help comparison. Minifying is discouraged; to save space, the specification suggests gzip.
- There is no file-level version. Each object carries the version of its own type.
- The same object cannot appear twice in the tree, so a repeated clip is written as an identical copy.
OTIO_SCHEMA
Every object is a JSON dictionary with a key OTIO_SCHEMA, whose value is a
type name, a full stop and a version number, such as Timeline.1 or
Clip.2. A reader looks at this first, because the type decides which of the
other fields it should expect. A key that the schema does not use is not an error: the
object keeps it as a dynamic field and writes it back unchanged.
How a reader treats an OTIO_SCHEMA value
From the C++ reader (deserialization.cpp, stringUtils.cpp and
typeRegistry.cpp, current main branch).
- A JSON object without an
OTIO_SCHEMAkey is not an OTIO object: it is read as a plain dictionary. OTIO_SCHEMAmust be a string; any other type is a type-mismatch error.- The reader first compares the whole string with the seven value types
RationalTime.1,TimeRange.1,Color.1,TimeTransform.1,SerializableObjectRef.1,V2d.1andBox2d.1(see special value types). Any other string is split at its last full stop into a name and a version. - A string with no full stop is an error (“badly formed schema version string”). The text after the
last full stop is read as a number by C++
std::stoi: it must begin with a digit (optionally after white space and a sign), and anything after the digits is ignored; text with no leading number, or a number too large for anint, is the same error. - A name the library has not registered becomes an
UnknownSchema, whatever its version, and is written back with its original name and version. - A registered name with a version higher than the highest the library knows for it
is an error (“has highest version n, but the requested schema version m is even
greater”); it is not turned into
UnknownSchema. - A version lower than the library’s is brought up to date by the upgrade functions, in order (see schema versions).
A file’s top-level object is usually a Timeline, but it can be any type,
such as a Clip or a RationalTime. An array is allowed, though
a SerializableCollection is preferred because it can carry metadata.
Readers should check for an unexpected top-level type and fail gracefully.
Validity rules a reader enforces
Where a reader built from the C++ library (deserialization.cpp,
serializableObject.h, composition.cpp, serialization.cpp,
typeRegistry.cpp, current main branch) accepts a file, and where it refuses it. The rules are
stated by what makes a file valid; the library’s wording of each message is not part of the format.
- A key repeated inside one JSON object is allowed, and the first value is the one used. The reader stores each key into a map with an insert that does not replace an existing entry, so later values for the same key are dropped. A writer must not rely on a later value winning.
- An object must be of the class its field needs. A field that holds an object of a
given class (for example
tracksneeds aStack,childrenneeds composable objects,media_referencesneeds media references,effectsneeds effects,markersneeds markers) accepts that class or a class derived from it, ornullwhere an object may be absent. A JSON value that is not an object, or an object of another class (aMarkerinchildren, for example), makes the file invalid (a type error). - An object cannot have two parents. When a composition (
Stack,Track) is read, each child is attached to it; a child that already belongs to another composition makes the file invalid. This can only happen through object references, where one object is named from twochildrenlists. - A downgrade needs every step. Writing with a target version map brings an object
down one version at a time. If the library has no downgrade function for one of the steps (for example
Markerfrom 2 to 1, which does not exist) the write fails; there is no partial downgrade. This is a rule for writers that target older versions, not for readers. - Marker 3 to 2 keeps a nameless colour as an object. The downgrade turns the
colorof aMarker.3into a name string only when the colour’snameis not empty. A colour whosenameis empty is left as theColor.1object, so the result is not a validMarker.2, whose colour should be a string.
How a timeline nests
A Timeline has a tracks field holding a Stack.
A stack’s children are tracks. Below that, children can be a
Clip, Gap, Stack, Track or
Transition. Parents use a children list, except
Timeline, which uses tracks.
Timelines, stacks, tracks, clips, media references and most other objects have a
metadata dictionary, which the library leaves alone. It can hold deeply
nested JSON and OTIO objects. The specification asks that metadata be grouped under
namespaces, to avoid collisions between workflows.
Special value types
These are written as JSON objects with the fields shown. An absent time, range, box or
colour is written as JSON null.
| Schema | Field | Type | Meaning |
|---|---|---|---|
RationalTime.1 | rate | double | Units per second. |
value | double | The time, in those units. | |
TimeRange.1 | duration | RationalTime | Length of the range. |
start_time | RationalTime | Start of the range. | |
TimeTransform.1 | offset | RationalTime | Added after scaling. |
rate | double | The rate of the result when above 0; otherwise the result keeps the rate of the time it is applied to. Default -1. | |
scale | double | Multiplies the value of the time. Default 1. | |
V2d.1 | x | double | Horizontal. |
y | double | Vertical. | |
Box2d.1 | min | V2d | Minimum corner. |
max | V2d | Maximum corner. | |
Color.1 | r | double | Red, sRGB-encoded, 0 to 1. |
g | double | Green, sRGB-encoded, 0 to 1. | |
b | double | Blue, sRGB-encoded, 0 to 1. | |
a | double | Alpha, 0 to 1. | |
name | string | Name. |
What the value types mean
From timeTransform.h and color.h (current main branch).
- TimeTransform applied to a time t (value v, rate r)
gives the time v ×
scaleat rate r, plusoffset; the sum is then converted to the rateratewhenrateis above 0, and otherwise to r, the rate of the time it was applied to (the defaultrateof -1 means “keep the rate”). Applied to aTimeRange, it transforms the start time and the exclusive end time and builds the range between them. Applied to another transform, offsets add, scales multiply and the rate is this transform’s when above 0, otherwise the other’s. - Color:
r,g,bandaare doubles holding sRGB transfer-function encoded values from 0 to 1. The header says the values are interoperable when accurate to within 1/255, and that the type is meant for user-interface elements such as marker and clip colours, not for image pixel content. The default colour is opaque white (1, 1, 1, 1) with an empty name. The reader does not check that the values lie between 0 and 1.
Rules for reading them
From deserialization.cpp (current main branch).
- Each is recognised by the exact whole string of its
OTIO_SCHEMA:RationalTime.1,TimeRange.1,TimeTransform.1,V2d.1,Box2d.1,Color.1andSerializableObjectRef.1. They have no upgrade or downgrade path, so another version number (RationalTime.2) is read as an ordinary schema name and fails as in the schema rules: unknown name, or too new. - Every field in the table is required, including
Color’sname. A missing key is a “key not found” error. A key the table does not list is dropped when the value type is built. - The fields are typed as follows. A double accepts a JSON floating-point number or a JSON
integer (an integer is converted);
NaNandInfare accepted too. An integer field (for examplestart_frameon an image sequence) accepts only a JSON integer, never a number with a fraction or exponent. Every JSON integer is read as a signed 64-bit value (an unsigned value above 263−1 keeps only its low 63 bits), and the library then narrows an image-sequence field to a 32-bitint. A string must be a JSON string, a boolean must betrueorfalse. - A value of the wrong type is an error, naming the key, the type wanted and the type found.
nullis not a number, string, boolean, dictionary, list or value type: it is accepted only (a) where the field is optional-valued (source_range,available_range,available_image_bounds,global_start_time,color, an optional boolean or number), where it means “absent”; (b) for a string field, where it reads as the empty string; and (c) where the field holds an object (such asmedia_reference), where it means “none”.
Named colours
The library defines these, used for markers among others. Unrecognised names upgrade to
white. Transparent belongs to the Color type; the released
Marker.2 has no such colour (see Marker.2).
| Name | r | g | b | a |
|---|---|---|---|---|
| Pink | 1.0 | 0.0 | 1.0 | 1.0 |
| Red | 1.0 | 0.0 | 0.0 | 1.0 |
| Orange | 1.0 | 0.5 | 0.0 | 1.0 |
| Yellow | 1.0 | 1.0 | 0.0 | 1.0 |
| Green | 0.0 | 1.0 | 0.0 | 1.0 |
| Cyan | 0.0 | 1.0 | 1.0 | 1.0 |
| Blue | 0.0 | 0.0 | 1.0 | 1.0 |
| Purple | 0.5 | 0.0 | 0.5 | 1.0 |
| Magenta | 1.0 | 0.0 | 1.0 | 1.0 |
| Black | 0.0 | 0.0 | 0.0 | 1.0 |
| White | 1.0 | 1.0 | 1.0 | 1.0 |
| Transparent | 0.0 | 0.0 | 0.0 | 0.0 |
Schema versions
Each type has its own version. A library release only creates objects at its current version, and it upgrades older ones on read through a chain of upgrade functions, one for each step. On write, a caller can ask for older versions, using a map from schema name to version, and downgrade functions take objects back step by step. Downgrade functions must be consecutive. Adding or removing a field does not always need a new version.
| Schema | Library releases | Change |
|---|---|---|
Clip.2 | 0.15.0 and later | Replaces the single media_reference field of Clip.1 with a media_references dictionary and an active_media_reference_key. |
Marker.2 | 0.14.0 to 0.18.1 | Field range is renamed marked_range. |
Marker.3 | 0.19.0 development | Field color changes from a string to a Color object. Names match case-insensitively. |
All other schemas are at version 1 in the published version maps from 0.14.0 onwards.
Three old names are aliases at version 1: Filler for Gap,
Sequence for Track, and
SerializeableCollection (the spelling is as written) for
SerializableCollection.
An object of an unknown schema is kept, with its original name and version, as
UnknownSchema, and written back the same way.