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

Refactor OTIO frame range collection #1060

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from
Open
Changes from 2 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
63ed2f2
Refactor OTIO frame range collection
jakubjezek001 Dec 13, 2024
9502b55
Merge branch 'develop' into feature/AY-7125_advanced-editorial-publis…
jakubjezek001 Dec 16, 2024
301e9ce
Merge branch 'develop' into feature/AY-7125_advanced-editorial-publis…
jakubjezek001 Jan 9, 2025
8ef1d38
Refactor OTIO frame range collection plugins
jakubjezek001 Jan 9, 2025
5d73b31
Refactor type hints in validation functions
jakubjezek001 Jan 9, 2025
f90bc8f
Update client/ayon_core/plugins/publish/collect_otio_frame_ranges.py
jakubjezek001 Jan 24, 2025
971c4ae
Refactor OTIO frame range collection plugin
jakubjezek001 Jan 24, 2025
be5eb08
Update client/ayon_core/plugins/publish/collect_otio_frame_ranges.py
jakubjezek001 Jan 30, 2025
f91baa0
Update client/ayon_core/plugins/publish/collect_otio_frame_ranges.py
jakubjezek001 Jan 30, 2025
888e81f
Fix OTIO frame range handling and add compatibility
jakubjezek001 Jan 30, 2025
1c943d7
Merge branch 'develop' into feature/AY-7125_advanced-editorial-publis…
jakubjezek001 Jan 30, 2025
de82d8b
Add handling for clips without available ranges
jakubjezek001 Jan 30, 2025
22769ef
Refactor frame range handling for clarity
jakubjezek001 Jan 30, 2025
6bb4937
Consolidate frame range detection from collect_otio_frame_ranges plugin.
robin-ynput Feb 11, 2025
396424c
Pull latest changes.
robin-ynput Feb 11, 2025
929e246
Merge branch 'develop' into feature/AY-7125_advanced-editorial-publis…
robin-ynput Feb 11, 2025
d0364cb
Fix lint.
robin-ynput Feb 11, 2025
47f80dd
Merge branch 'develop' into feature/AY-7125_advanced-editorial-publis…
jakubjezek001 Feb 12, 2025
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
87 changes: 70 additions & 17 deletions client/ayon_core/plugins/publish/collect_otio_frame_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,65 @@ def process(self, instance):
# Not all hosts can import these modules.
import opentimelineio as otio
from ayon_core.pipeline.editorial import (
get_media_range_with_retimes,
otio_range_to_frame_range,
otio_range_with_handles
)

if not instance.data.get("otioClip"):
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
self.log.debug("Skipping collect OTIO frame range.")
return

# get basic variables
otio_clip = instance.data["otioClip"]
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
workfile_start = instance.data["workfileFrameStart"]

# get ranges
otio_tl_range = otio_clip.range_in_parent()
otio_tl_range_handles = otio_range_with_handles(
otio_tl_range, instance)

# convert to frames
range_convert = otio_range_to_frame_range
tl_start, tl_end = range_convert(otio_tl_range)
tl_start_h, tl_end_h = range_convert(otio_tl_range_handles)
frame_start = workfile_start
frame_end = frame_start + otio.opentime.to_frames(
otio_tl_range.duration, otio_tl_range.duration.rate) - 1

data = {
"frameStart": frame_start,
"frameEnd": frame_end,
"clipIn": tl_start,
"clipOut": tl_end - 1,
"clipInH": tl_start_h,
"clipOutH": tl_end_h - 1,
}
instance.data.update(data)
self.log.debug(
"_ data: {}".format(pformat(data)))
self.log.debug(
"_ instance.data: {}".format(pformat(instance.data)))


class CollectOtioSourceFrameRanges(pyblish.api.InstancePlugin):
"""Getting otio ranges from otio_clip

Adding timeline and source ranges to instance data"""

label = "Collect OTIO Frame Ranges (with media range)"
order = pyblish.api.CollectorOrder - 0.07
families = ["shot", "clip"]
hosts = ["hiero", "flame"]
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved

def process(self, instance):
# Not all hosts can import these modules.
import opentimelineio as otio
from ayon_core.pipeline.editorial import (
get_media_range_with_retimes,
otio_range_to_frame_range,
otio_range_with_handles,
)

if not instance.data.get("otioClip"):
self.log.debug("Skipping collect OTIO frame range.")
return
Expand All @@ -42,15 +96,13 @@ def process(self, instance):
otio_tl_range = otio_clip.range_in_parent()
otio_src_range = otio_clip.source_range
otio_avalable_range = otio_clip.available_range()
otio_tl_range_handles = otio_range_with_handles(
otio_tl_range, instance)
otio_src_range_handles = otio_range_with_handles(
otio_src_range, instance)
otio_tl_range_handles = otio_range_with_handles(otio_tl_range, instance)
otio_src_range_handles = otio_range_with_handles(otio_src_range, instance)

# get source avalable start frame
src_starting_from = otio.opentime.to_frames(
otio_avalable_range.start_time,
otio_avalable_range.start_time.rate)
otio_avalable_range.start_time, otio_avalable_range.start_time.rate
)

# convert to frames
range_convert = otio_range_to_frame_range
Expand All @@ -59,16 +111,19 @@ def process(self, instance):
src_start, src_end = range_convert(otio_src_range)
src_start_h, src_end_h = range_convert(otio_src_range_handles)
frame_start = workfile_start
frame_end = frame_start + otio.opentime.to_frames(
otio_tl_range.duration, otio_tl_range.duration.rate) - 1
frame_end = (
frame_start
+ otio.opentime.to_frames(
otio_tl_range.duration, otio_tl_range.duration.rate
)
- 1
)

# in case of retimed clip and frame range should not be retimed
if workfile_source_duration:
# get available range trimmed with processed retimes
retimed_attributes = get_media_range_with_retimes(
otio_clip, 0, 0)
self.log.debug(
">> retimed_attributes: {}".format(retimed_attributes))
retimed_attributes = get_media_range_with_retimes(otio_clip, 0, 0)
self.log.debug(">> retimed_attributes: {}".format(retimed_attributes))
media_in = int(retimed_attributes["mediaIn"])
media_out = int(retimed_attributes["mediaOut"])
frame_end = frame_start + (media_out - media_in) + 1
Expand All @@ -87,7 +142,5 @@ def process(self, instance):
"sourceEndH": src_starting_from + src_end_h - 1,
}
instance.data.update(data)
self.log.debug(
"_ data: {}".format(pformat(data)))
self.log.debug(
"_ instance.data: {}".format(pformat(instance.data)))
self.log.debug("_ data: {}".format(pformat(data)))
self.log.debug("_ instance.data: {}".format(pformat(instance.data)))
Loading