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 default global scale value if missing in the annotation hook #647

Merged
Merged
Changes from all 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
19 changes: 19 additions & 0 deletions src/plugins/rv-packages/otio_reader/annotation_hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# *****************************************************************************


import logging
import effectHook
import opentimelineio as otio
from rv import commands, extra_commands
Expand Down Expand Up @@ -58,6 +59,24 @@ def hook_function(in_timeline, argument_map=None) -> None:
)

global_scale = argument_map.get("global_scale")
if global_scale is None:
logging.warning(
"Unable to get the global scale, using the aspect ratio of the first media file"
)
try:
first_source_node = commands.sourcesAtFrame(0)[0]
media_info = commands.sourceMediaInfo(first_source_node)
height = media_info["height"]
aspect_ratio = media_info["width"] / height
eloisebrosseau marked this conversation as resolved.
Show resolved Hide resolved
except Exception:
logging.exception(
"Unable to determine aspect ratio, using default value of 16:9"
)
aspect_ratio = 1920 / 1080
finally:
scale = aspect_ratio / 16
global_scale = otio.schema.V2d(scale, scale)

points_property = f"{pen_component}.points"
width_property = f"{pen_component}.width"

Expand Down
Loading