resolve: swap family with families

This commit is contained in:
Jakub Jezek 2020-12-23 17:57:35 +01:00
parent 88b276aa09
commit 127eb01138
No known key found for this signature in database
GPG key ID: C4B96E101D2A47F3
3 changed files with 95 additions and 19 deletions

View file

@ -636,7 +636,8 @@ class PublishClip:
"parents": self.parents,
"hierarchyData": hierarchy_formating_data,
"subset": self.subset,
"families": [self.subset_family]
"family": self.subset_family,
"families": ["clip"]
}
def _convert_to_entity(self, key):

View file

@ -19,7 +19,7 @@ class CollectOcioFrameRanges(pyblish.api.InstancePlugin):
label = "Collect OTIO Frame Ranges"
order = pyblish.api.CollectorOrder - 0.58
families = ["clip", "shot"]
families = ["shot"]
hosts = ["resolve"]
def process(self, instance):

View file

@ -3,13 +3,10 @@
Requires:
instance -> otio_clip
Optional:
instance -> review
Provides:
instance -> otioReviewClips
"""
import os
import clique
import opentimelineio as otio
import pyblish.api
@ -25,6 +22,9 @@ class CollectOcioSubsetResources(pyblish.api.InstancePlugin):
hosts = ["resolve"]
def process(self, instance):
if not instance.data.get("representations"):
instance.data["representations"] = list()
# get basic variables
otio_clip = instance.data["otioClip"]
@ -36,6 +36,26 @@ class CollectOcioSubsetResources(pyblish.api.InstancePlugin):
trimmed_media_range = pype.lib.trim_media_range(
otio_avalable_range, otio_src_range_handles)
a_frame_start, a_frame_end = pype.lib.otio_range_to_frame_range(
otio_avalable_range)
frame_start, frame_end = pype.lib.otio_range_to_frame_range(
trimmed_media_range)
# fix frame_start and frame_end frame to be in range of
if frame_start < a_frame_start:
frame_start = a_frame_start
if frame_end > a_frame_end:
frame_end = a_frame_end
instance.data.update({
"frameStart": frame_start,
"frameEnd": frame_end
})
self.log.debug(
"_ otio_avalable_range: {}".format(otio_avalable_range))
self.log.debug(
"_ trimmed_media_range: {}".format(trimmed_media_range))
@ -53,16 +73,13 @@ class CollectOcioSubsetResources(pyblish.api.InstancePlugin):
if metadata.get("padding"):
is_sequence = True
first, last = pype.lib.otio_range_to_frame_range(
trimmed_media_range)
self.log.info(
"first-last: {}-{}".format(first, last))
"frame_start-frame_end: {}-{}".format(frame_start, frame_end))
if is_sequence:
# file sequence way
if hasattr(media_ref, "target_url_base"):
dirname = media_ref.target_url_base
self.staging_dir = media_ref.target_url_base
head = media_ref.name_prefix
tail = media_ref.name_suffix
collection = clique.Collection(
@ -71,19 +88,77 @@ class CollectOcioSubsetResources(pyblish.api.InstancePlugin):
padding=media_ref.frame_zero_padding
)
collection.indexes.update(
[i for i in range(first, (last + 1))])
# TODO: add representation
self.log.debug((dirname, collection))
[i for i in range(frame_start, (frame_end + 1))])
self.log.debug(collection)
repre = self._create_representation(
frame_start, frame_end, collection=collection)
self.log.debug(repre)
else:
# in case it is file sequence but not new OTIO schema
# `ImageSequenceReference`
path = media_ref.target_url
dir_path, collection = pype.lib.make_sequence_collection(
collection_data = pype.lib.make_sequence_collection(
path, trimmed_media_range, metadata)
self.staging_dir, collection = collection_data
# TODO: add representation
self.log.debug((dir_path, collection))
self.log.debug(collection)
repre = self._create_representation(
frame_start, frame_end, collection=collection)
self.log.debug(repre)
else:
path = media_ref.target_url
# TODO: add representation
dirname, filename = os.path.split(media_ref.target_url)
self.staging_dir = dirname
self.log.debug(path)
repre = self._create_representation(
frame_start, frame_end, file=filename)
self.log.debug(repre)
if repre:
instance.data
instance.data["representations"].append(repre)
def _create_representation(self, start, end, **kwargs):
"""
Creating representation data.
Args:
start (int): start frame
end (int): end frame
kwargs (dict): optional data
Returns:
dict: representation data
"""
# create default representation data
representation_data = {
"frameStart": start,
"frameEnd": end,
"stagingDir": self.staging_dir
}
if kwargs.get("collection"):
collection = kwargs.get("collection")
files = [f for f in collection]
ext = collection.format("{tail}")
representation_data.update({
"name": ext[1:],
"ext": ext[1:],
"files": files,
"frameStart": start,
"frameEnd": end,
})
return representation_data
if kwargs.get("file"):
file = kwargs.get("file")
ext = os.path.splitext(file)[-1]
representation_data.update({
"name": ext[1:],
"ext": ext[1:],
"files": file,
"frameStart": start,
"frameEnd": end,
})
return representation_data