Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add otiotool functionality to Raven #63

Open
timlehr opened this issue Sep 20, 2024 · 1 comment
Open

Add otiotool functionality to Raven #63

timlehr opened this issue Sep 20, 2024 · 1 comment

Comments

@timlehr
Copy link
Collaborator

timlehr commented Sep 20, 2024

Feature suggestion

OTIO ships with a CLI tool called otiotool that combines a bunch of common OTIO operations into one command line tool.
By calling out to the tool via a subprocess (or implementing some of these functions in C++) we could greatly enhance the editing capabilities of Raven.

Here is the help output of OTIO describing the available features:

otiotool --help
usage: otiotool [-h] [--input PATHs) [PATH(s) ...]] [--video-only]
                [--audio-only] [--only-tracks-with-name NAME(s) [NAME(s) ...]]
                [--only-tracks-with-index INDEX(es) [INDEX(es) ...]]
                [--only-clips-with-name NAME(s) [NAME(s) ...]]
                [--only-clips-with-name-regex REGEX(es) [REGEX(es) ...]]
                [--remove-transitions] [--trim START END] [--flatten TYPE]
                [--keep-flattened-tracks] [--stack] [--concat]
                [--relink-by-name FOLDER(s) [FOLDER(s) ...]]
                [--copy-media-to-folder FOLDER]
                [--remove-metadata-key KEY(s) [KEY(s) ...]] [--redact]
                [--stats] [--list-clips] [--list-tracks] [--list-media]
                [--verify-media] [--list-markers]
                [--inspect NAME(s) [NAME(s ...]] [--downgrade FAMILY:VERSION]
                [--list-versions] [--output PATH]

otiotool = a multi-purpose command line utility for working with OpenTimelineIO.

This tool works in phases, as follows:
1. Input
    Input files provided by the "--input <filename>" argument(s) are read into
    memory. Files may be OTIO format, or any format supported by adapter
    plugins.

2. Filtering
    Options such as --video-only, --audio-only, --only-tracks-with-name,
    -only-tracks-with-index, --only-clips-with-name,
    --only-clips-with-name-regex, --remove-transitions, and --trim will remove
    content. Only the tracks, clips, etc. that pass all of the filtering options
    provided are passed to the next phase.

3. Combine
    If specified, the --stack, --concat, and --flatten operations are
    performed (in that order) to combine all of the input timeline(s) into one.

4. Relink
    The --relink-by-name option, will scan the specified folder(s) looking for
    files which match the name of each clip in the input timeline(s).
    If matching files are found, clips will be relinked to those files (using
    file:// URLs). Clip names are matched to filenames ignoring file extension.
    If specified, the --copy-media-to-folder option, will copy or download
    all linked media, and relink the OTIO to reference the local copies.

5. Remove/Redact
    The --remove-metadata-key option allows you to remove a specific piece of
    metadata from all objects.
    If specified, the --redact option, will remove ALL metadata and rename all
    objects in the OTIO with generic names (e.g. "Track 1", "Clip 17", etc.)

6. Inspect
    Options such as --stats, --list-clips, --list-tracks, --list-media,
    --verify-media, --list-markers, and --inspect will examine the OTIO and
    print information to standard output.

7. Output
    Finally, if the "--output <filename>" option is specified, the resulting
    OTIO will be written to the specified file. The extension of the output
    filename is used to determine the format of the output (e.g. OTIO or any
    format supported by the adapter plugins.) If you need to output an older
    schema version, see the --downgrade option.

optional arguments:
  -h, --help            show this help message and exit
  --input PATH(s) [PATH(s) ...], -i PATH(s) [PATH(s) ...]
                        Input file path(s). All formats supported by adapter
                        plugins are supported. Use '-' to read OTIO from
                        standard input.
  --video-only, -v      Output only video tracks
  --audio-only, -a      Output only audio tracks
  --only-tracks-with-name NAME(s) [NAME(s) ...]
                        Output tracks with these name(s)
  --only-tracks-with-index INDEX(es) [INDEX(es) ...]
                        Output tracks with these indexes (1 based, in same
                        order as --list-tracks)
  --only-clips-with-name NAME(s) [NAME(s) ...]
                        Output only clips with these name(s)
  --only-clips-with-name-regex REGEX(es) [REGEX(es) ...]
                        Output only clips with names matching the given
                        regular expression pattern (e.g. '[Ii]nterview
                        [0-9]+')
  --remove-transitions  Remove all transitions
  --trim START END, -t START END
                        Trim from START to END, each specified as seconds or
                        HH:MM:SS:FF timecode (matching the timeline's rate)
  --flatten TYPE, -f TYPE
                        Flatten multiple tracks into one. TYPE must be 'video'
                        or 'audio' or 'all'.
  --keep-flattened-tracks
                        When used with --flatten, the new flat track is added
                        above the others instead of replacing them.
  --stack, -s           Stack multiple input files into one timeline
  --concat, -c          Concatenate multiple input files end-to-end into one
                        timeline
  --relink-by-name FOLDER(s) [FOLDER(s) ...]
                        Scan the specified folder looking for filenames which
                        match each clip's name. If found, clips are relinked
                        to those files.
  --copy-media-to-folder FOLDER
                        Copy or download all linked media to the specified
                        folder and relink all media references to the copies
  --remove-metadata-key KEY(s) [KEY(s) ...]
                        Remove one or more metadata dictionary top-level keys
                        from all objects.
  --redact              Remove all metadata, names, etc. leaving only the
                        timeline structure
  --stats               List statistics about the result, including start,
                        end, and duration
  --list-clips          List each clip's name
  --list-tracks         List each track's name
  --list-media          List each referenced media URL
  --verify-media        Verify that each referenced media URL exists (for
                        local media only)
  --list-markers        List summary of all markers
  --inspect NAME(s) [NAME(s) ...]
                        Inspect details of clips with names matching the given
                        regular expression pattern (e.g. 'SFX.*-TEMP')
  --downgrade FAMILY:VERSION
                        Downgrade OTIO schema. Only relevant when --output is
                        used to output an OTIO file. FAMILY:VERSION specifies
                        which schema family and version to use. If FAMILY: is
                        omitted, the default OTIO_CORE: is used. For example
                        `--downgrade OTIO_CORE:0.14.0` is equivalent to
                        `--downgrade 0.14.0`. See https://opentimelineio.readt
                        hedocs.io/en/latest/tutorials/versioning-schemas.html
                        for details.
  --list-versions       List available versions for the --downgrade option.
  --output PATH, -o PATH
                        Output file. All formats supported by adapter plugins
                        are supported. Use '-' to write OTIO to standard
                        output.

Examples:

Combine multiple files into one, by joining them end-to-end:
otiotool -i titles.otio -i feature.otio -i credits.otio --concat -o full.otio

Layer multiple files on top of each other in a stack:
otiotool -i background.otio -i foreground.otio --stack -o composite.otio

Verify that all referenced media files are accessible:
otiotool -i playlist.otio --verify-media

Inspect specific audio clips in detail:
otiotool -i playlist.otio --only-audio --list-tracks --inspect "Interview"
@jminor
Copy link
Member

jminor commented Nov 14, 2024

See also #60 for pros/cons of subprocess pipe vs embedding Python into Raven. (Subprocess pipe is preferred).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants