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

#1677 otiotool verify ranges #1779

Merged
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 35 additions & 6 deletions src/py-opentimelineio/opentimelineio/console/otiotool.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def main():
args.list_media or
args.verify_media or
args.list_tracks or
args.list_markers)
args.list_markers or
args.verify_ranges)
if should_summarize:
for timeline in timelines:
summarize_timeline(
Expand All @@ -146,6 +147,7 @@ def main():
args.list_media,
args.verify_media,
args.list_markers,
args.verify_ranges,
timeline)

# Final Phase: Output
Expand Down Expand Up @@ -207,8 +209,8 @@ def parse_arguments():

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.
--verify-media, --list-markers, --verify-ranges, and --inspect
will examine the OTIO and print information to standard output.

7. Output
Finally, if the "--output <filename>" option is specified, the resulting
Expand Down Expand Up @@ -397,6 +399,12 @@ def parse_arguments():
action='store_true',
help="List summary of all markers"
)
parser.add_argument(
"--verify-ranges",
action='store_true',
help="""Verify that each clip in a timeline has a source range
within the available range of media"""
)
parser.add_argument(
"--inspect",
type=str,
Expand Down Expand Up @@ -852,7 +860,7 @@ def inspect_timelines(name_regex, timeline):


def summarize_timeline(list_tracks, list_clips, list_media, verify_media,
list_markers, timeline):
list_markers, verify_ranges, timeline):
"""Print a summary of a timeline, optionally listing the tracks, clips, media,
and/or markers inside it."""
print("TIMELINE:", timeline.name)
Expand All @@ -861,8 +869,29 @@ def summarize_timeline(list_tracks, list_clips, list_media, verify_media,
if list_tracks:
print(f"TRACK: {child.name} ({child.kind})")
if isinstance(child, otio.schema.Clip):
if list_clips:
print(" CLIP:", child.name)
if list_clips or verify_ranges:
if verify_ranges:
range_msg = ""
try:
source = child.source_range
available = child.available_range()

src_start = source.start_time.value
src_dur = source.duration.value
avail_start = available.start_time.value
avail_dur = available.duration.value

starts_early = src_start < avail_start
ends_late = (src_dur - src_start) > (avail_dur - avail_start)
jminor marked this conversation as resolved.
Show resolved Hide resolved
if starts_early or ends_late:
range_msg = "SOURCE MEDIA OUT OF BOUNDS"
else:
range_msg = "IN BOUNDS"
except Exception: # available range is, well, unavailable
pass
jminor marked this conversation as resolved.
Show resolved Hide resolved
print(" CLIP:", child.name, range_msg)
else:
print(" CLIP:", child.name)
if list_media or verify_media:
try:
url = child.media_reference.target_url
Expand Down
Loading