From 6069471eff8703bee8e87c39dc13c8a5a8a4c160 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:38:20 +0200 Subject: [PATCH 1/8] use better method name --- client/ayon_core/plugins/publish/extract_thumbnail.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 943f169b1c..b5d2d8a82e 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -219,7 +219,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): ) # If the input can read by OIIO then use OIIO method for # conversion otherwise use ffmpeg - repre_thumb_created = self._create_thumbnail_oiio( + repre_thumb_created = self._create_colorspace_thumbnail( full_input_path, full_output_path, colorspace_data @@ -382,7 +382,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): return ext in IMAGE_EXTENSIONS or ext in VIDEO_EXTENSIONS - def _create_thumbnail_oiio( + def _create_colorspace_thumbnail( self, src_path, dst_path, From 0232e4641a69cd69f004a3dbb968c5008aebd927 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:38:37 +0200 Subject: [PATCH 2/8] remove irrelevant log --- client/ayon_core/plugins/publish/extract_thumbnail.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index b5d2d8a82e..e796e35ae2 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -229,12 +229,6 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): # oiiotool isn't available or representation is not having # colorspace data if not repre_thumb_created: - if oiio_supported: - self.log.debug( - "Converting with FFMPEG because input" - " can't be read by OIIO." - ) - repre_thumb_created = self._create_thumbnail_ffmpeg( full_input_path, full_output_path ) From c0ac022cf78c54f646e2f51d4b194653f7747158 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:38:48 +0200 Subject: [PATCH 3/8] fallback to oiio if ffmpeg conversion fails --- .../plugins/publish/extract_thumbnail.py | 45 ++++++++++++++++++- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index e796e35ae2..316d7a4ed9 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -6,6 +6,7 @@ import re import pyblish.api from ayon_core.lib import ( + get_oiio_tool_args, get_ffmpeg_tool_args, get_ffprobe_data, @@ -210,6 +211,12 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): full_output_path = os.path.join(dst_staging, jpeg_file) colorspace_data = repre.get("colorspaceData") + # NOTE We should find out what is happening here. Why don't we + # use oiiotool all the time if it is available? Only possible + # reason might be that video files should be converted using + # ffmpeg, but other then that, we should use oiio all the time. + # - We should also probably get rid of the ffmpeg settings... + # only use OIIO if it is supported and representation has # colorspace data if oiio_supported and colorspace_data: @@ -234,6 +241,11 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): ) # Skip representation and try next one if wasn't created + if not repre_thumb_created and oiio_supported: + repre_thumb_created = self._create_thumbnail_oiio( + full_input_path, full_output_path + ) + if not repre_thumb_created: continue @@ -449,9 +461,38 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): return True + def _create_thumbnail_oiio(self, src_path, dst_path): + self.log.debug(f"Extracting thumbnail with OIIO: {dst_path}") + + try: + resolution_arg = self._get_resolution_arg("oiiotool", src_path) + except RuntimeError: + return False + + oiio_cmd = get_oiio_tool_args( + "oiiotool", + "-a", src_path, + "--ch", "R,G,B", + ) + oiio_cmd.extend(resolution_arg) + oiio_cmd.extend(("-o", dst_path)) + self.log.debug("Running: {}".format(" ".join(oiio_cmd))) + try: + run_subprocess(oiio_cmd, logger=self.log) + return True + except Exception: + self.log.warning( + "Failed to create thumbnail using oiiotool", + exc_info=True + ) + return False + def _create_thumbnail_ffmpeg(self, src_path, dst_path): - self.log.debug("Extracting thumbnail with FFMPEG: {}".format(dst_path)) - resolution_arg = self._get_resolution_arg("ffmpeg", src_path) + try: + resolution_arg = self._get_resolution_arg("ffmpeg", src_path) + except RuntimeError: + return False + ffmpeg_path_args = get_ffmpeg_tool_args("ffmpeg") ffmpeg_args = self.ffmpeg_args or {} From bb850e9bdcdf5c4a4fa3b2909d043b0533f3a1ed Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:59:14 +0200 Subject: [PATCH 4/8] use review channels to create the thumbnail --- .../plugins/publish/extract_thumbnail.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 316d7a4ed9..4553c1de86 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -16,7 +16,11 @@ from ayon_core.lib import ( path_to_subprocess_arg, run_subprocess, ) -from ayon_core.lib.transcoding import oiio_color_convert +from ayon_core.lib.transcoding import ( + oiio_color_convert, + get_oiio_input_and_channel_args, + get_oiio_info_for_input, +) from ayon_core.lib.transcoding import VIDEO_EXTENSIONS, IMAGE_EXTENSIONS @@ -469,10 +473,16 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): except RuntimeError: return False + input_info = get_oiio_info_for_input(src_path, logger=self.log) + input_arg, channels_arg = get_oiio_input_and_channel_args(input_info) oiio_cmd = get_oiio_tool_args( "oiiotool", - "-a", src_path, - "--ch", "R,G,B", + input_arg, src_path, + # Tell oiiotool which channels should be put to top stack + # (and output) + "--ch", channels_arg, + # Use first subimage + "--subimage", "0" ) oiio_cmd.extend(resolution_arg) oiio_cmd.extend(("-o", dst_path)) From 455db40985044760b38014b442d5643ee4a58138 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 11:59:29 +0200 Subject: [PATCH 5/8] allow 'rgba' layer name to be used if is available --- client/ayon_core/lib/transcoding.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 75f0c8bc4d..77f383f7a8 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -420,12 +420,16 @@ def get_review_info_by_layer_name(channel_names): channel = last_part[0].upper() rgba_by_layer_name[layer_name][channel] = channel_name - # Put empty layer to the beginning of the list + # Put empty layer or 'rgba' to the beginning of the list # - if input has R, G, B, A channels they should be used for review if "" in layer_names_order: layer_names_order.remove("") layer_names_order.insert(0, "") + elif "rgba" in layer_names_order: + layer_names_order.remove("rgba") + layer_names_order.insert(0, "rgba") + output = [] for layer_name in layer_names_order: rgba_layer_info = rgba_by_layer_name[layer_name] From 0f7176c2d20d7a5460d5da9bb62eecd287945acb Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 12:03:56 +0200 Subject: [PATCH 6/8] avoid duplicated code --- client/ayon_core/lib/transcoding.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/client/ayon_core/lib/transcoding.py b/client/ayon_core/lib/transcoding.py index 77f383f7a8..127bd3bac4 100644 --- a/client/ayon_core/lib/transcoding.py +++ b/client/ayon_core/lib/transcoding.py @@ -422,13 +422,12 @@ def get_review_info_by_layer_name(channel_names): # Put empty layer or 'rgba' to the beginning of the list # - if input has R, G, B, A channels they should be used for review - if "" in layer_names_order: - layer_names_order.remove("") - layer_names_order.insert(0, "") - - elif "rgba" in layer_names_order: - layer_names_order.remove("rgba") - layer_names_order.insert(0, "rgba") + # NOTE They are iterated in reversed order because they're inserted to + # the beginning of 'layer_names_order' -> last added will be first. + for name in reversed(["", "rgba"]): + if name in layer_names_order: + layer_names_order.remove(name) + layer_names_order.insert(0, name) output = [] for layer_name in layer_names_order: From 257a20c263886f8d4b16b48ae0f826c851ecf4a0 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 12:29:53 +0200 Subject: [PATCH 7/8] grammar fix Co-authored-by: Roy Nieterau --- client/ayon_core/plugins/publish/extract_thumbnail.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 4553c1de86..79876f7974 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -244,7 +244,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): full_input_path, full_output_path ) - # Skip representation and try next one if wasn't created + # Skip representation and try next one if wasn't created if not repre_thumb_created and oiio_supported: repre_thumb_created = self._create_thumbnail_oiio( full_input_path, full_output_path From b508c3ffbb8364009c058cfcaa24e0c235bed928 Mon Sep 17 00:00:00 2001 From: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> Date: Wed, 8 Oct 2025 14:09:20 +0200 Subject: [PATCH 8/8] add warning logs if thumbnail creation fails --- client/ayon_core/plugins/publish/extract_thumbnail.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/ayon_core/plugins/publish/extract_thumbnail.py b/client/ayon_core/plugins/publish/extract_thumbnail.py index 79876f7974..b5885178d0 100644 --- a/client/ayon_core/plugins/publish/extract_thumbnail.py +++ b/client/ayon_core/plugins/publish/extract_thumbnail.py @@ -471,6 +471,9 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): try: resolution_arg = self._get_resolution_arg("oiiotool", src_path) except RuntimeError: + self.log.warning( + "Failed to create thumbnail using oiio", exc_info=True + ) return False input_info = get_oiio_info_for_input(src_path, logger=self.log) @@ -501,6 +504,9 @@ class ExtractThumbnail(pyblish.api.InstancePlugin): try: resolution_arg = self._get_resolution_arg("ffmpeg", src_path) except RuntimeError: + self.log.warning( + "Failed to create thumbnail using ffmpeg", exc_info=True + ) return False ffmpeg_path_args = get_ffmpeg_tool_args("ffmpeg")