mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
feat(global, resolve): otio publishing wip
This commit is contained in:
parent
f7f7b657bb
commit
eeeef0d33d
5 changed files with 63 additions and 40 deletions
|
|
@ -2,6 +2,10 @@ import sys
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from opentimelineio import opentime
|
from opentimelineio import opentime
|
||||||
|
import pype
|
||||||
|
|
||||||
|
from .otio import davinci_export as otio_export
|
||||||
|
|
||||||
from pype.api import Logger
|
from pype.api import Logger
|
||||||
|
|
||||||
log = Logger().get_logger(__name__, "resolve")
|
log = Logger().get_logger(__name__, "resolve")
|
||||||
|
|
@ -649,20 +653,7 @@ def get_reformated_path(path, padded=True):
|
||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
def get_otio_clip_instance_data(track_item_data):
|
def create_otio_time_range_from_track_item_data(track_item_data):
|
||||||
"""
|
|
||||||
Return otio objects for timeline, track and clip
|
|
||||||
|
|
||||||
Args:
|
|
||||||
track_item_data (dict): track_item_data from list returned by
|
|
||||||
resolve.get_current_track_items()
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
dict: otio clip with parent objects
|
|
||||||
|
|
||||||
"""
|
|
||||||
from .otio import davinci_export as otio_export
|
|
||||||
|
|
||||||
track_item = track_item_data["clip"]["item"]
|
track_item = track_item_data["clip"]["item"]
|
||||||
project = track_item_data["project"]
|
project = track_item_data["project"]
|
||||||
timeline = track_item_data["sequence"]
|
timeline = track_item_data["sequence"]
|
||||||
|
|
@ -670,15 +661,40 @@ def get_otio_clip_instance_data(track_item_data):
|
||||||
|
|
||||||
frame_start = int(track_item.GetStart() - timeline_start)
|
frame_start = int(track_item.GetStart() - timeline_start)
|
||||||
frame_duration = int(track_item.GetDuration())
|
frame_duration = int(track_item.GetDuration())
|
||||||
self.project_fps = project.GetSetting("timelineFrameRate")
|
fps = project.GetSetting("timelineFrameRate")
|
||||||
|
|
||||||
otio_clip_range = otio_export.create_otio_time_range(
|
return otio_export.create_otio_time_range(
|
||||||
frame_start, frame_duration, self.project_fps)
|
frame_start, frame_duration, fps)
|
||||||
|
|
||||||
# create otio clip and add it to track
|
|
||||||
otio_clip = otio_export.create_otio_clip(track_item)
|
|
||||||
|
|
||||||
return {
|
def get_otio_clip_instance_data(otio_timeline, track_item_data):
|
||||||
"otioClip": otio_clip,
|
"""
|
||||||
"otioClipRange": otio_clip_range
|
Return otio objects for timeline, track and clip
|
||||||
}
|
|
||||||
|
Args:
|
||||||
|
track_item_data (dict): track_item_data from list returned by
|
||||||
|
resolve.get_current_track_items()
|
||||||
|
otio_timeline (otio.schema.Timeline): otio object
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
dict: otio clip object
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
track_item = track_item_data["clip"]["item"]
|
||||||
|
track_name = track_item_data["track"]["name"]
|
||||||
|
timeline_range = create_otio_time_range_from_track_item_data(
|
||||||
|
track_item_data)
|
||||||
|
|
||||||
|
for otio_clip in otio_timeline.each_clip():
|
||||||
|
track_name = otio_clip.parent().name
|
||||||
|
parent_range = otio_clip.range_in_parent()
|
||||||
|
if track_name not in track_name:
|
||||||
|
continue
|
||||||
|
if otio_clip.name not in track_item.GetName():
|
||||||
|
continue
|
||||||
|
if pype.lib.is_overlapping_otio_ranges(
|
||||||
|
parent_range, timeline_range, strict=True):
|
||||||
|
return {"otioClip": otio_clip}
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ from .ffmpeg_utils import (
|
||||||
)
|
)
|
||||||
|
|
||||||
from .editorial import (
|
from .editorial import (
|
||||||
is_overlapping,
|
is_overlapping_otio_ranges,
|
||||||
convert_otio_range_to_frame_range
|
convert_otio_range_to_frame_range
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -88,6 +88,6 @@ __all__ = [
|
||||||
"source_hash",
|
"source_hash",
|
||||||
"_subprocess",
|
"_subprocess",
|
||||||
|
|
||||||
"is_overlapping",
|
"is_overlapping_otio_ranges",
|
||||||
"convert_otio_range_to_frame_range"
|
"convert_otio_range_to_frame_range"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ def convert_otio_range_to_frame_range(otio_range):
|
||||||
return start, end
|
return start, end
|
||||||
|
|
||||||
|
|
||||||
def is_overlapping(test_range, main_range, strict=False):
|
def is_overlapping_otio_ranges(test_otio_range, main_otio_range, strict=False):
|
||||||
test_start, test_end = convert_otio_range_to_frame_range(test_range)
|
test_start, test_end = convert_otio_range_to_frame_range(test_otio_range)
|
||||||
main_start, main_end = convert_otio_range_to_frame_range(main_range)
|
main_start, main_end = convert_otio_range_to_frame_range(main_otio_range)
|
||||||
covering_exp = bool(
|
covering_exp = bool(
|
||||||
(test_start <= main_start) and (test_end >= main_end)
|
(test_start <= main_start) and (test_end >= main_end)
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ Requires:
|
||||||
import opentimelineio as otio
|
import opentimelineio as otio
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
from pype.lib import (
|
from pype.lib import (
|
||||||
is_overlapping,
|
is_overlapping_otio_ranges,
|
||||||
convert_otio_range_to_frame_range
|
convert_otio_range_to_frame_range
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -26,21 +26,22 @@ class CollectOcioReview(pyblish.api.InstancePlugin):
|
||||||
review_track_name = instance.data["review"]
|
review_track_name = instance.data["review"]
|
||||||
master_layer = instance.data["masterLayer"]
|
master_layer = instance.data["masterLayer"]
|
||||||
otio_timeline_context = instance.context.data["otioTimeline"]
|
otio_timeline_context = instance.context.data["otioTimeline"]
|
||||||
otio_clip_range = instance.data["otioClipRange"]
|
otio_clip = instance.data["otioClip"]
|
||||||
|
otio_clip_range = otio_clip.range_in_parent()
|
||||||
# skip if master layer is False
|
# skip if master layer is False
|
||||||
if not master_layer:
|
if not master_layer:
|
||||||
return
|
return
|
||||||
|
|
||||||
for otio_clip in otio_timeline_context.each_clip():
|
for _otio_clip in otio_timeline_context.each_clip():
|
||||||
track_name = otio_clip.parent().name
|
track_name = _otio_clip.parent().name
|
||||||
parent_range = otio_clip.range_in_parent()
|
parent_range = _otio_clip.range_in_parent()
|
||||||
if track_name not in review_track_name:
|
if track_name not in review_track_name:
|
||||||
continue
|
continue
|
||||||
if isinstance(otio_clip, otio.schema.Clip):
|
if isinstance(_otio_clip, otio.schema.Clip):
|
||||||
if is_overlapping(parent_range, otio_clip_range, strict=False):
|
if is_overlapping_otio_ranges(
|
||||||
|
parent_range, otio_clip_range, strict=False):
|
||||||
self.create_representation(
|
self.create_representation(
|
||||||
otio_clip, otio_clip_range, instance)
|
_otio_clip, otio_clip_range, instance)
|
||||||
|
|
||||||
def create_representation(self, otio_clip, to_otio_range, instance):
|
def create_representation(self, otio_clip, to_otio_range, instance):
|
||||||
to_timeline_start, to_timeline_end = convert_otio_range_to_frame_range(
|
to_timeline_start, to_timeline_end = convert_otio_range_to_frame_range(
|
||||||
|
|
@ -50,10 +51,12 @@ class CollectOcioReview(pyblish.api.InstancePlugin):
|
||||||
source_start, source_end = convert_otio_range_to_frame_range(
|
source_start, source_end = convert_otio_range_to_frame_range(
|
||||||
otio_clip.source_range)
|
otio_clip.source_range)
|
||||||
media_reference = otio_clip.media_reference
|
media_reference = otio_clip.media_reference
|
||||||
|
metadata = media_reference.metadata
|
||||||
available_start, available_end = convert_otio_range_to_frame_range(
|
available_start, available_end = convert_otio_range_to_frame_range(
|
||||||
media_reference.available_range)
|
media_reference.available_range)
|
||||||
path = media_reference.target_url
|
path = media_reference.target_url
|
||||||
self.log.debug(path)
|
self.log.debug(path)
|
||||||
|
self.log.debug(metadata)
|
||||||
self.log.debug((available_start, available_end))
|
self.log.debug((available_start, available_end))
|
||||||
self.log.debug((source_start, source_end))
|
self.log.debug((source_start, source_end))
|
||||||
self.log.debug((timeline_start, timeline_end))
|
self.log.debug((timeline_start, timeline_end))
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ class CollectInstances(pyblish.api.ContextPlugin):
|
||||||
hosts = ["resolve"]
|
hosts = ["resolve"]
|
||||||
|
|
||||||
def process(self, context):
|
def process(self, context):
|
||||||
|
otio_timeline = context.data["otioTimeline"]
|
||||||
selected_track_items = resolve.get_current_track_items(
|
selected_track_items = resolve.get_current_track_items(
|
||||||
filter=True, selecting_color=resolve.publish_clip_color)
|
filter=True, selecting_color=resolve.publish_clip_color)
|
||||||
|
|
||||||
|
|
@ -68,9 +69,12 @@ class CollectInstances(pyblish.api.ContextPlugin):
|
||||||
"tags": tag_data,
|
"tags": tag_data,
|
||||||
})
|
})
|
||||||
|
|
||||||
# otio
|
# otio clip data
|
||||||
otio_data = resolve.get_otio_clip_instance_data(track_item_data)
|
otio_data = resolve.get_otio_clip_instance_data(
|
||||||
data.update(otio_data)
|
otio_timeline, track_item_data)
|
||||||
|
|
||||||
|
if otio_data:
|
||||||
|
data.update(otio_data)
|
||||||
|
|
||||||
# create instance
|
# create instance
|
||||||
instance = context.create_instance(**data)
|
instance = context.create_instance(**data)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue