Skip to content

cornball-ai/RcppOTIO

Repository files navigation

RcppOTIO

R bindings for OpenTimelineIO (OTIO), built as an Rcpp wrapper over the OTIO C++ library (0.18.x).

It covers the time types, the schema classes, tree construction, JSON round-trips, and the edit algorithms (overwrite, insert, trim, slice, slip, slide, ripple, roll, fill, remove) plus track_trimmed_to_range and flatten_stack. Clips carry the full media_references map (multiple keyed references with an active key). Schema versioning is supported too: register_upgrade_function / register_downgrade_function take R callbacks over the schema dictionary, to_json_string accepts target_schema_versions to downgrade on write, and type_version_map reports the registered schema versions.

Design

  • Value types are plain classed R values. RationalTime, TimeRange, and TimeTransform are immutable values, so they live as classed R objects (a named numeric for RationalTime, small lists for the others) and convert to/from C++ only at the call boundary. They print, compare, and serialize naturally in R.
  • Schema objects are external pointers with OTIO's ref-counting. Timeline, Stack, Track, Clip, and the rest are SerializableObjects with object identity, parentage, and intrusive reference counting. Each R handle holds a heap Retainer<SerializableObject> inside an external pointer; the object self-deletes only when the last reference (R handle or tree parent) goes away. You never delete one directly.
  • Names follow OTIO exactly. source_range, range_in_parent, append_child, media_reference, and so on, with field<- setters where OTIO has a setter. No invented aliases.
  • Addressing is by position and reference, never by name. A name is a label; sibling items may share one. Tree children are addressed by 1-based position (translated to OTIO's 0-based index at the boundary) and by object reference.

Example

library(RcppOTIO)

tl   <- Timeline("my timeline")
trk  <- Track("V1", kind = "Video")
clip <- Clip("shot",
             ExternalReference("shot.mov"),
             source_range = TimeRange(RationalTime(0, 24), RationalTime(48, 24)))

append_child(trk, clip)
append_child(tracks(tl), trk)

duration(tl)                       # RationalTime(value = 48, rate = 24)
range_in_parent(clip)              # where the clip sits in the track
find_clips(tl)                     # list of clips, recursively

js  <- to_json_string(tl)          # OTIO JSON
tl2 <- from_json_string(js)
is_equivalent_to(tl, tl2)          # TRUE

Relationship to rotio

rotio is the lightweight sibling: the same OTIO object model and naming, implemented in pure R with no compiled code. RcppOTIO binds the real C++ library; rotio uses it in Suggests as an optional validation oracle, round-tripping its JSON and edit-algorithm output through libopentimelineio in parity tests. If you need OTIO in R without a C++ toolchain, use rotio. If you want the reference implementation itself, you're in the right place.

Building these packages is also what surfaced OpenTimelineIO#2025, an edit-algorithm fix found while parity-testing.

Install

install.packages("RcppOTIO", repos = c(
  "https://cornball-ai.github.io/drat",
  "https://cloud.r-project.org"
))

Requirements

The OpenTimelineIO C++ library (>= 0.18) and Imath headers must be installed (default /usr/local). Override at install time with:

R CMD INSTALL --configure-vars='OTIO_HOME=/opt/otio' RcppOTIO

License

Apache License 2.0, matching upstream OpenTimelineIO.

About

R bindings for the OpenTimelineIO C++ library

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors