mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge branch 'bugfix/extract_thumbnail_oiio' into enhancement/OP-6659_thumbnail-color-managed
This commit is contained in:
commit
94e6fabf72
3 changed files with 67 additions and 21 deletions
|
|
@ -1 +1 @@
|
|||
Subproject commit 63266607ceb972a61484f046634ddfc9eb0b5757
|
||||
Subproject commit ff15c700771e719cc5f3d561ac5d6f7590623986
|
||||
|
|
@ -1149,8 +1149,9 @@ def convert_colorspace(
|
|||
target_colorspace=None,
|
||||
view=None,
|
||||
display=None,
|
||||
additional_input_args=None,
|
||||
additional_command_args=None,
|
||||
logger=None
|
||||
logger=None,
|
||||
):
|
||||
"""Convert source file from one color space to another.
|
||||
|
||||
|
|
@ -1169,6 +1170,8 @@ def convert_colorspace(
|
|||
view (str): name for viewer space (ocio valid)
|
||||
both 'view' and 'display' must be filled (if 'target_colorspace')
|
||||
display (str): name for display-referred reference space (ocio valid)
|
||||
both 'view' and 'display' must be filled (if 'target_colorspace')
|
||||
additional_input_args (list): input arguments for oiiotool
|
||||
additional_command_args (list): arguments for oiiotool (like binary
|
||||
depth for .dpx)
|
||||
logger (logging.Logger): Logger used for logging.
|
||||
|
|
@ -1178,12 +1181,21 @@ def convert_colorspace(
|
|||
if logger is None:
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
oiio_cmd = get_oiio_tool_args(
|
||||
"oiiotool",
|
||||
# prepare main oiio command args
|
||||
args = [
|
||||
input_path,
|
||||
# Don't add any additional attributes
|
||||
"--nosoftwareattrib",
|
||||
"--colorconfig", config_path
|
||||
]
|
||||
|
||||
# prepend any additional args if available
|
||||
if additional_input_args:
|
||||
args = additional_input_args + args
|
||||
|
||||
oiio_cmd = get_oiio_tool_args(
|
||||
"oiiotool",
|
||||
*args
|
||||
)
|
||||
|
||||
if all([target_colorspace, view, display]):
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@ import tempfile
|
|||
import pyblish.api
|
||||
from openpype.lib import (
|
||||
get_ffmpeg_tool_args,
|
||||
get_oiio_tool_args,
|
||||
is_oiio_supported,
|
||||
|
||||
run_subprocess,
|
||||
path_to_subprocess_arg,
|
||||
)
|
||||
from openpype.lib.transcoding import convert_colorspace
|
||||
|
||||
|
||||
class ExtractThumbnail(pyblish.api.InstancePlugin):
|
||||
|
|
@ -25,7 +25,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
hosts = ["shell", "fusion", "resolve", "traypublisher", "substancepainter"]
|
||||
enabled = False
|
||||
|
||||
# presetable attribute
|
||||
# presentable attribute
|
||||
ffmpeg_args = None
|
||||
|
||||
def process(self, instance):
|
||||
|
|
@ -94,17 +94,26 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
filename = os.path.splitext(input_file)[0]
|
||||
jpeg_file = filename + "_thumb.jpg"
|
||||
full_output_path = os.path.join(dst_staging, jpeg_file)
|
||||
colorspace_data = repre.get("colorspaceData")
|
||||
|
||||
if oiio_supported:
|
||||
self.log.debug("Trying to convert with OIIO")
|
||||
# only use OIIO if it is supported and representation has
|
||||
# colorspace data
|
||||
if oiio_supported and colorspace_data:
|
||||
self.log.debug(
|
||||
"Trying to convert with OIIO "
|
||||
"with colorspace data: {}".format(colorspace_data)
|
||||
)
|
||||
# If the input can read by OIIO then use OIIO method for
|
||||
# conversion otherwise use ffmpeg
|
||||
thumbnail_created = self.create_thumbnail_oiio(
|
||||
full_input_path, full_output_path
|
||||
full_input_path,
|
||||
full_output_path,
|
||||
colorspace_data
|
||||
)
|
||||
|
||||
# Try to use FFMPEG if OIIO is not supported or for cases when
|
||||
# oiiotool isn't available
|
||||
# oiiotool isn't available or representation is not having
|
||||
# colorspace data
|
||||
if not thumbnail_created:
|
||||
if oiio_supported:
|
||||
self.log.debug(
|
||||
|
|
@ -138,7 +147,7 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
break
|
||||
|
||||
if not thumbnail_created:
|
||||
self.log.warning("Thumbanil has not been created.")
|
||||
self.log.warning("Thumbnail has not been created.")
|
||||
|
||||
def _is_review_instance(self, instance):
|
||||
# TODO: We should probably handle "not creating" of thumbnail
|
||||
|
|
@ -173,17 +182,40 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
filtered_repres.append(repre)
|
||||
return filtered_repres
|
||||
|
||||
def create_thumbnail_oiio(self, src_path, dst_path):
|
||||
self.log.debug("Extracting thumbnail with OIIO: {}".format(dst_path))
|
||||
oiio_cmd = get_oiio_tool_args(
|
||||
"oiiotool",
|
||||
"-a", src_path,
|
||||
"-o", dst_path
|
||||
)
|
||||
self.log.debug("running: {}".format(" ".join(oiio_cmd)))
|
||||
def create_thumbnail_oiio(
|
||||
self,
|
||||
src_path,
|
||||
dst_path,
|
||||
colorspace_data,
|
||||
):
|
||||
"""Create thumbnail using OIIO tool oiiotool
|
||||
|
||||
Args:
|
||||
src_path (str): path to source file
|
||||
dst_path (str): path to destination file
|
||||
colorspace_data (dict): colorspace data from representation
|
||||
keys:
|
||||
colorspace (str)
|
||||
config (dict)
|
||||
display (Optional[str])
|
||||
view (Optional[str])
|
||||
|
||||
Returns:
|
||||
str: path to created thumbnail
|
||||
"""
|
||||
self.log.info("Extracting thumbnail {}".format(dst_path))
|
||||
|
||||
try:
|
||||
run_subprocess(oiio_cmd, logger=self.log)
|
||||
return True
|
||||
convert_colorspace(
|
||||
src_path,
|
||||
dst_path,
|
||||
colorspace_data["config"]["path"],
|
||||
colorspace_data["colorspace"],
|
||||
display=colorspace_data.get("display"),
|
||||
view=colorspace_data.get("view"),
|
||||
additional_input_args=["-i:ch=R,G,B"],
|
||||
logger=self.log,
|
||||
)
|
||||
except Exception:
|
||||
self.log.warning(
|
||||
"Failed to create thumbnail using oiiotool",
|
||||
|
|
@ -191,6 +223,8 @@ class ExtractThumbnail(pyblish.api.InstancePlugin):
|
|||
)
|
||||
return False
|
||||
|
||||
return dst_path
|
||||
|
||||
def create_thumbnail_ffmpeg(self, src_path, dst_path):
|
||||
self.log.debug("Extracting thumbnail with FFMPEG: {}".format(dst_path))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue