|
| 1 | +# otiotool Tutorial |
| 2 | + |
| 3 | +`otiotool` is a command-line utility in OpenTimelineIO for inspecting, manipulating, and transforming OTIO timeline files. This tutorial covers its main features and usage patterns, with practical examples. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +`otiotool` is included with several other command line utilities as part of the |
| 8 | +OpenTimelineIO Python module. You can install it via typical Python utilities |
| 9 | +like `pip`, etc. See [Quickstart](./quickstart) for details. |
| 10 | + |
| 11 | +> [!TIP] |
| 12 | +> If you have |
| 13 | +[uv installed](https://docs.astral.sh/uv/), then you can use `otiotool` with |
| 14 | +this handy shortcut without having to deal with any installation: |
| 15 | + |
| 16 | +```bash |
| 17 | +uvx --from opentimelineio otiotool |
| 18 | +``` |
| 19 | + |
| 20 | +## Basic Usage |
| 21 | + |
| 22 | +`otiotool` reads one or more OTIO timeline files, optionally makes changes to the timelines, and outputs a text report and/or a new OTIO file with the result. |
| 23 | + |
| 24 | +To run `otiotool` for reporting, use options like `--list-clips` or `--list-tracks`. The report output is |
| 25 | +printed to the console: |
| 26 | + |
| 27 | +```bash |
| 28 | +otiotool --input <input_file.otio> [more inputs...] [options] |
| 29 | +``` |
| 30 | + |
| 31 | +Report output can be redirected from standard output |
| 32 | +to a file like any terminal program: |
| 33 | + |
| 34 | +```bash |
| 35 | +otiotool --input <input_file.otio> [more inputs...] [options] > report.txt |
| 36 | +``` |
| 37 | + |
| 38 | +To run `otiotool` to create a new OTIO file, use: |
| 39 | + |
| 40 | +```bash |
| 41 | +otiotool --input <input_file.otio> [more inputs...] [options] --output <output_file.otio> |
| 42 | +``` |
| 43 | + |
| 44 | +Many of `otiotool`'s command line options have a long and a short form. For example: `--input` is also `-i`, and `--output` is `-o`. |
| 45 | + |
| 46 | +Multiple options of `otiotool` can be combined into |
| 47 | +a single invocation. For example, you might read a file, |
| 48 | +trim it, remove some tracks, verify missing media into |
| 49 | +a report and output a new file all in one command like this: |
| 50 | + |
| 51 | +```bash |
| 52 | +otiotool -i multitrack.otio -trim 20 30 --video-only --verify-media -o output.otio > report.txt |
| 53 | +``` |
| 54 | + |
| 55 | +For a complete listing of all options use `otiotool -h`. |
| 56 | + |
| 57 | +## Phases |
| 58 | + |
| 59 | +Unlike some other command line tools, the order in which most options appear on |
| 60 | +the command line does not matter. For example these two commands do the same thing: |
| 61 | + |
| 62 | +```bash |
| 63 | +otiotool -i input.otio --flatten -o output.otio |
| 64 | +otiotool --flatten -o output.otio -i input.otio |
| 65 | +``` |
| 66 | + |
| 67 | +The only time that command line argument ordering matters is when multiple input files are specified and operations like `--stack` and `--concat` combine them |
| 68 | +together. |
| 69 | + |
| 70 | +Instead, the features of this tool work in phases, as follows: |
| 71 | + |
| 72 | +1. Input |
| 73 | + |
| 74 | + Input files provided by the `--input <filename>` argument(s) are read into |
| 75 | + memory. Files may be OTIO format, or any format supported by adapter |
| 76 | + plugins. |
| 77 | + |
| 78 | +2. Filtering |
| 79 | + |
| 80 | + Options such as `--video-only`, `--audio-only`, `--only-tracks-with-name`, |
| 81 | + `--only-tracks-with-index`, `--only-clips-with-name`, |
| 82 | + `--only-clips-with-name-regex`, `--remove-transitions`, and `--trim` will remove |
| 83 | + content. Only the tracks, clips, etc. that pass all of the filtering options |
| 84 | + provided are passed to the next phase. |
| 85 | + |
| 86 | +3. Combine |
| 87 | + |
| 88 | + If specified, the `--stack` or `--concat` operations are |
| 89 | + performed (in that order) to combine all of the input timeline(s) into one. |
| 90 | + |
| 91 | +4. Flatten |
| 92 | + |
| 93 | + If `--flatten` is specified, multiple tracks are flattened into one. |
| 94 | + |
| 95 | +5. Relink |
| 96 | + |
| 97 | + The `--relink-by-name` option, will scan the specified folder(s) looking for |
| 98 | + files which match the name of each clip in the input timeline(s). |
| 99 | + If matching files are found, clips will be relinked to those files (using |
| 100 | + file:// URLs). Clip names are matched to filenames ignoring file extension. |
| 101 | + If specified, the `--copy-media-to-folder` option, will copy or download |
| 102 | + all linked media, and relink the OTIO to reference the local copies. |
| 103 | + |
| 104 | +6. Remove/Redact |
| 105 | + |
| 106 | + The `--remove-metadata-key` option allows you to remove a specific piece of |
| 107 | + metadata from all objects. |
| 108 | + If specified, the `--redact` option, will remove ALL metadata and rename all |
| 109 | + objects in the OTIO with generic names (e.g. "Track 1", "Clip 17", etc.) |
| 110 | + |
| 111 | +7. Inspect |
| 112 | + |
| 113 | + Options such as `--stats`, `--list-clips`, `--list-tracks`, `--list-media`, |
| 114 | + `--verify-media`, `--list-markers`, `--verify-ranges`, and `--inspect` |
| 115 | + will examine the OTIO and print information to standard output. |
| 116 | + |
| 117 | +8. Output |
| 118 | + |
| 119 | + Finally, if the `--output <filename>` option is specified, the resulting |
| 120 | + OTIO will be written to the specified file. The extension of the output |
| 121 | + filename is used to determine the format of the output (e.g. OTIO or any |
| 122 | + format supported by the adapter plugins.) If you need to output an older |
| 123 | + schema version, see the `--downgrade` option. |
| 124 | + |
| 125 | + |
| 126 | +## Listing Timeline Contents |
| 127 | + |
| 128 | +### List Tracks |
| 129 | +Prints all tracks in the timeline: |
| 130 | +```bash |
| 131 | +otiotool -i multitrack.otio --list-tracks |
| 132 | +``` |
| 133 | +Output: |
| 134 | +``` |
| 135 | +TIMELINE: OTIO TEST - multitrack.Exported.01 |
| 136 | +TRACK: Sequence (Video) |
| 137 | +TRACK: Sequence 2 (Video) |
| 138 | +TRACK: Sequence 3 (Video) |
| 139 | +``` |
| 140 | + |
| 141 | +### List Clips, Markers, etc. |
| 142 | +Prints all clips and markers in the timeline: |
| 143 | +```bash |
| 144 | +otiotool -i screening_example.otio --list-clips --list-markers |
| 145 | +``` |
| 146 | +Output: |
| 147 | +``` |
| 148 | +TIMELINE: Example_Screening.01 |
| 149 | + CLIP: ZZ100_501 (LAY3) |
| 150 | + CLIP: ZZ100_502A (LAY3) |
| 151 | + CLIP: ZZ100_503A (LAY1) |
| 152 | + CLIP: ZZ100_504C (LAY1) |
| 153 | + MARKER: global: 00:59:49:13 local: 01:00:01:14 duration: 0.0 color: RED name: ANIM FIX NEEDED |
| 154 | + MARKER: global: 00:59:50:13 local: 01:00:02:14 duration: 0.0 color: PINK |
| 155 | + ... |
| 156 | +``` |
| 157 | + |
| 158 | +## Filtering Tracks and Clips |
| 159 | + |
| 160 | +### Video or Audio Only |
| 161 | +List only video or audio clips: |
| 162 | +```bash |
| 163 | +otiotool -i premiere_example.otio --video-only --list-clips |
| 164 | +otiotool -i premiere_example.otio --audio-only --list-clips |
| 165 | +``` |
| 166 | + |
| 167 | +### Filter by Track Name or Index |
| 168 | +```bash |
| 169 | +otiotool -i multitrack.otio --only-tracks-with-name "Sequence 3" --list-clips |
| 170 | +otiotool -i multitrack.otio --only-tracks-with-index 3 --list-clips |
| 171 | +``` |
| 172 | + |
| 173 | +Indexes for `--only-tracks-with-index` begin at 1 for the first track, and that you often want to use it in combination with `--video-only` or `--audio-only`. |
| 174 | + |
| 175 | +### Filter Clips by Name or Regex |
| 176 | +```bash |
| 177 | +otiotool -i premiere_example.otio --list-clips --only-clips-with-name "sc01_sh010_anim.mov" |
| 178 | +otiotool -i premiere_example.otio --list-clips --only-clips-with-name-regex "sh\d+_anim" |
| 179 | +``` |
| 180 | + |
| 181 | +The `--only-clips-with-name-regex` option uses the [Python Regular Expression syntax](https://docs.python.org/3/library/re.html). |
| 182 | + |
| 183 | +## Media Information |
| 184 | + |
| 185 | +### List Media References |
| 186 | +```bash |
| 187 | +otiotool -i multitrack.otio --list-tracks --list-clips --list-media |
| 188 | +``` |
| 189 | + |
| 190 | +### Verify Media Existence |
| 191 | +Checks if media files exist. Only local file paths are checked by `otiotool`, not URLs or other non-file path media references. |
| 192 | +```bash |
| 193 | +otiotool -i premiere_example.otio --verify-media |
| 194 | +``` |
| 195 | + |
| 196 | +## Statistics and Inspection |
| 197 | + |
| 198 | +### Print Timeline Stats |
| 199 | +```bash |
| 200 | +otiotool -i multitrack.otio --stats |
| 201 | +``` |
| 202 | +Output: |
| 203 | +``` |
| 204 | +Name: OTIO TEST - multitrack.Exported.01 |
| 205 | +Start: 00:00:00:00 |
| 206 | +End: 00:02:16:18 |
| 207 | +Duration: 00:02:16:18 |
| 208 | +``` |
| 209 | + |
| 210 | +### Inspect Items |
| 211 | +Show details for a specific item: |
| 212 | +```bash |
| 213 | +otiotool -i multitrack.otio --inspect "KOLL" |
| 214 | +``` |
| 215 | +Output: |
| 216 | +``` |
| 217 | +TIMELINE: OTIO TEST - multitrack.Exported.01 |
| 218 | + ITEM: KOLL-HD.mp4 (<class 'opentimelineio._otio.Clip'>) |
| 219 | + source_range: TimeRange(RationalTime(0, 24), RationalTime(640, 24)) |
| 220 | + trimmed_range: TimeRange(RationalTime(0, 24), RationalTime(640, 24)) |
| 221 | + visible_range: TimeRange(RationalTime(0, 24), RationalTime(640, 24)) |
| 222 | + range_in_parent: TimeRange(RationalTime(1198, 24), RationalTime(640, 24)) |
| 223 | + trimmed range in timeline: TimeRange(RationalTime(1198, 24), RationalTime(640, 24)) |
| 224 | + visible range in timeline: TimeRange(RationalTime(1198, 24), RationalTime(640, 24)) |
| 225 | + range in Sequence 3 (<class 'opentimelineio._otio.Track'>): TimeRange(RationalTime(1198, 24), RationalTime(640, 24)) |
| 226 | + range in NestedScope (<class 'opentimelineio._otio.Stack'>): TimeRange(RationalTime(1198, 24), RationalTime(640, 24)) |
| 227 | +``` |
| 228 | + |
| 229 | +## Input/Output |
| 230 | + |
| 231 | +### Input File(s) |
| 232 | + |
| 233 | +Multiple input files can be specified via `--input` like this: |
| 234 | + |
| 235 | +```bash |
| 236 | +otiotool -i one.otio two.otio three.otio --concat -o result.otio |
| 237 | +``` |
| 238 | + |
| 239 | +> [!NOTE] |
| 240 | +> When `otiotool` is given multiple inputs, the order of those inputs will affect the outcome of `--concat`, `--stack`, and any text reports printed to the console. |
| 241 | +
|
| 242 | +### Output File |
| 243 | + |
| 244 | +Modifications to the timeline(s) can be written out to a new file with the |
| 245 | +`--output <filename.otio>` option. |
| 246 | + |
| 247 | +> [!NOTE] |
| 248 | +> The input files are never modified unless the |
| 249 | +output path specifies the same file, in which case that file will be overwritten (not recommended). |
| 250 | + |
| 251 | +### Multiple Timelines |
| 252 | + |
| 253 | +If the result is a single timeline, then the output file will contain that timeline |
| 254 | +as expected. However, if there were multiple input files and those timelines |
| 255 | +were not combined with `--concat` or `--stack` then the output will be a single |
| 256 | +file containing a SerializableCollection with multiple timelines. This is a |
| 257 | +supported OTIO feature, but many tools and workflows expect only a single |
| 258 | +timeline in an OTIO file. |
| 259 | + |
| 260 | +### Standard In/Out |
| 261 | + |
| 262 | +You can chain `otiotool` with other tools on the command |
| 263 | +line. |
| 264 | + |
| 265 | +If you specify the `--output` file as a single `-` then the resulting OTIO will |
| 266 | +be printed as text to stdout instead of a file. |
| 267 | + |
| 268 | +```bash |
| 269 | +otiotool -i multitrack.otio --video-only -o - | grep MissingReference |
| 270 | +``` |
| 271 | + |
| 272 | +You can also use `-` as an |
| 273 | +input from stdin. |
| 274 | + |
| 275 | +```bash |
| 276 | +curl https://example.com/some/path/premiere_example.otio | otiotool -i - --verify-media --stats |
| 277 | +``` |
| 278 | + |
| 279 | +### Format Conversion |
| 280 | + |
| 281 | +The format of the input and output file is inferred |
| 282 | +from the filename extension. It can be `.otio` for an OTIO file, or any other |
| 283 | +file format supported by an available [OTIO adapter plugin](./adapters). |
| 284 | + |
| 285 | +Thus `otiotool` |
| 286 | +can operate much like `otioconvert` however some more advanced conversion |
| 287 | +options are only available in `otioconvert`. If you need both, you can write |
| 288 | +to an intermediate OTIO file and convert to/from the other format in a separate |
| 289 | +step. |
| 290 | + |
| 291 | +```bash |
| 292 | +otiotool -i multitrack.otio --flatten video --video-only -o single-track.otio |
| 293 | +``` |
| 294 | + |
| 295 | +Combined with conversion to EDL (via [this adapter plugin](https://github.com/OpenTimelineIO/otio-cmx3600-adapter)): |
| 296 | +```bash |
| 297 | +uvx --from opentimelineio --with otio-cmx3600-adapter otiotool -i multitrack.otio --flatten video --video-only -o single-track.edl |
| 298 | +``` |
| 299 | + |
| 300 | +## Timeline Manipulation |
| 301 | + |
| 302 | +### Trim Timeline |
| 303 | +Trim to a time range: |
| 304 | +```bash |
| 305 | +otiotool -i multitrack.otio --trim 20.5 40 -o output.otio |
| 306 | +otiotool -i multitrack.otio --trim 00:01:00:00 00:02:00:00 -o output.otio |
| 307 | +``` |
| 308 | + |
| 309 | +The start and end times for `--trim` can be either a floating point number of seconds |
| 310 | +or timecode `HH:MM:SS:FF` in the frame rate inferred from the timeline itself. |
| 311 | + |
| 312 | +### Flatten Tracks |
| 313 | +Combine multiple tracks into one with `--flatten <TYPE>` where `TYPE` is either `video`, `audio`, or `all`: |
| 314 | +```bash |
| 315 | +otiotool -i multitrack.otio --flatten video -o output.otio --list-tracks |
| 316 | +``` |
| 317 | + |
| 318 | +### Stack or Concatenate Timelines |
| 319 | + |
| 320 | +> [!NOTE] |
| 321 | +> With `--stack` and `--concat` the order of the input files affects the outcome. |
| 322 | +
|
| 323 | +When concatenated, the inputs are assembled in the order listed, so the first input is earliest on the output timeline. |
| 324 | + |
| 325 | +Concat Example: |
| 326 | +```bash |
| 327 | +otiotool -i opening.otio end_credits.otio --concat -o output.otio |
| 328 | +``` |
| 329 | +``` |
| 330 | +
|
| 331 | +When stacked, video tracks layer bottom-to-top, so the video tracks of the second input are layered above the first input. This follows conventional video/audio ordering where video tracks are layered numerically increasing upward (V2 is above V1). Audio tracks are layered in the opposite order, since traditionally audio tracks are layered numerically increasing downward (A2 is below A1). |
| 332 | +
|
| 333 | +Stack Example: |
| 334 | +```bash |
| 335 | +otiotool -i a.otio b.otio --stack -o output.otio |
| 336 | +``` |
| 337 | + |
| 338 | +### Redact Timeline |
| 339 | +Replace names of clips, tracks, etc. with generic labels: |
| 340 | +```bash |
| 341 | +otiotool -i multitrack.otio --redact -o output.otio --list-clips |
| 342 | +``` |
| 343 | +Output: |
| 344 | +``` |
| 345 | +TIMELINE: Timeline #1 |
| 346 | + CLIP: Clip #1 |
| 347 | + CLIP: Clip #2 |
| 348 | + CLIP: Clip #3 |
| 349 | + CLIP: Clip #4 |
| 350 | + CLIP: Clip #5 |
| 351 | +``` |
| 352 | + |
| 353 | +This feature is meant for cases where you want to share an OTIO without leaking |
| 354 | +sensitive information that might appear in a clip name, metadata, etc. For |
| 355 | +example when filing a bug report. |
| 356 | +Please look at the file contents after running this to ensure everything you |
| 357 | +care about was handled. |
| 358 | + |
| 359 | +### Remove Transitions |
| 360 | +Remove all transitions: |
| 361 | +```bash |
| 362 | +otiotool -i transition.otio --remove-transitions -o output.otio |
| 363 | +``` |
| 364 | + |
| 365 | +## OTIO Schema Versions |
| 366 | + |
| 367 | +When `otiotool` reads an older OTIO format, it will automatically upgrade |
| 368 | +the file to the newest schema supported by `otiotool`. |
| 369 | + |
| 370 | +When working with an application or workflow that requires an older OTIO |
| 371 | +file format, you can use `otiotool` to downgrade an OTIO to a specific schema |
| 372 | +version which is compatible. |
| 373 | + |
| 374 | +See [Versioning Schemas](./versioning-schemas) to understand this in detail. |
| 375 | + |
| 376 | +```bash |
| 377 | +otiotool --list-versions |
| 378 | +``` |
| 379 | +Output: |
| 380 | +``` |
| 381 | +Available versions for --downgrade FAMILY:VERSION |
| 382 | + OTIO_CORE:0.14.0 |
| 383 | + OTIO_CORE:0.15.0 |
| 384 | + OTIO_CORE:0.16.0 |
| 385 | + OTIO_CORE:0.17.0 |
| 386 | +``` |
| 387 | + |
| 388 | +```bash |
| 389 | +otiotool -i multitrack.otio --downgrade OTIO_CORE:0.14.0 -o old-format.otio |
| 390 | +``` |
0 commit comments