From 68db3d9c117df46aaf883a344aef61d26752aa22 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Wed, 6 Nov 2024 15:48:19 +0100 Subject: [PATCH] Add logic to extract colorspace from metadata if available. - Extract colorspace from media metadata for review clips. - Update instance data with the extracted colorspace information. --- .../plugins/publish/collect_otio_review.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/client/ayon_core/plugins/publish/collect_otio_review.py b/client/ayon_core/plugins/publish/collect_otio_review.py index 69cf9199e7..04422391c5 100644 --- a/client/ayon_core/plugins/publish/collect_otio_review.py +++ b/client/ayon_core/plugins/publish/collect_otio_review.py @@ -95,9 +95,46 @@ class CollectOtioReview(pyblish.api.InstancePlugin): instance.data["label"] = label + " (review)" instance.data["families"] += ["review", "ftrack"] instance.data["otioReviewClips"] = otio_review_clips + self.log.info( "Creating review track: {}".format(otio_review_clips)) + # get colorspace from metadata if available + if len(otio_review_clips) >= 1 and any( + # lets make sure any clip with media reference is found + ( + clip + for clip in otio_review_clips + if isinstance(clip, otio.schema.Clip) + and clip.media_reference + ) + ): + # get metadata from first clip + # get colorspace from metadata if available + # check if resolution is the same as source + r_otio_cl = next( + ( + clip + for clip in otio_review_clips + if isinstance(clip, otio.schema.Clip) + and clip.media_reference + ), + None, + ) + + # get metadata from first clip with media reference + media_ref = r_otio_cl.media_reference + media_metadata = media_ref.metadata + + # TODO: we might need some alternative method since + # native OTIO exports do not support ayon metadata + if review_colorspace := media_metadata.get( + "ayon.source.colorspace" + ): + instance.data["reviewColorspace"] = review_colorspace + self.log.info( + "Review colorspace: {}".format(review_colorspace)) + self.log.debug( "_ instance.data: {}".format(pformat(instance.data))) self.log.debug(