Skip to content

Commit

Permalink
Add a default value if the aspect ratio is invalid
Browse files Browse the repository at this point in the history
Signed-off-by: Éloïse Brosseau <[email protected]>
  • Loading branch information
eloisebrosseau committed Dec 5, 2024
1 parent 21daaa1 commit 15c0236
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 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 @@ -59,12 +60,19 @@ def hook_function(in_timeline, argument_map=None) -> None:

global_scale = argument_map.get("global_scale")
if global_scale is None:
first_source_node = commands.sourcesAtFrame(0)[0]
media_info = commands.sourceMediaInfo(first_source_node)
height = media_info["height"]
aspect_ratio = media_info["width"] / height
scale = aspect_ratio / 16
global_scale = otio.schema.V2d(scale, scale)
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
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

0 comments on commit 15c0236

Please sign in to comment.