Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Use colorspace data when creating thumbnail.
Browse files Browse the repository at this point in the history
  • Loading branch information
tokejepsen committed Jul 6, 2023
1 parent 587b98d commit f814db2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
13 changes: 9 additions & 4 deletions openpype/lib/transcoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,7 +1056,8 @@ def convert_colorspace(
view=None,
display=None,
additional_command_args=None,
logger=None
logger=None,
input_args=None
):
"""Convert source file from one color space to another.
Expand Down Expand Up @@ -1084,13 +1085,17 @@ def convert_colorspace(
if logger is None:
logger = logging.getLogger(__name__)

oiio_cmd = [
get_oiio_tools_path(),
oiio_cmd = [get_oiio_tools_path()]

if input_args:
oiio_cmd.extend(input_args)

oiio_cmd.extend([
input_path,
# Don't add any additional attributes
"--nosoftwareattrib",
"--colorconfig", config_path
]
])

if all([target_colorspace, view, display]):
raise ValueError("Colorspace and both screen and display"
Expand Down
51 changes: 33 additions & 18 deletions openpype/plugins/publish/extract_thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
run_subprocess,
path_to_subprocess_arg,
)
from openpype.lib.transcoding import convert_colorspace


class ExtractThumbnail(pyblish.api.InstancePlugin):
Expand Down Expand Up @@ -98,8 +99,18 @@ def process(self, instance):
self.log.debug("Trying to convert with OIIO")
# If the input can read by OIIO then use OIIO method for
# conversion otherwise use ffmpeg
colorspace_data = repre["colorspaceData"]
source_colorspace = colorspace_data["colorspace"]
config_path = colorspace_data.get("config", {}).get("path")
display = colorspace_data["display"]
view = colorspace_data["view"]
thumbnail_created = self.create_thumbnail_oiio(
full_input_path, full_output_path
full_input_path,
full_output_path,
config_path,
source_colorspace,
display,
view
)

# Try to use FFMPEG if OIIO is not supported or for cases when
Expand Down Expand Up @@ -172,24 +183,28 @@ def _get_filtered_repres(self, instance):
filtered_repres.append(repre)
return filtered_repres

def create_thumbnail_oiio(self, src_path, dst_path):
def create_thumbnail_oiio(
self,
src_path,
dst_path,
config_path,
source_colorspace,
display,
view
):
self.log.info("Extracting thumbnail {}".format(dst_path))
oiio_tool_path = get_oiio_tools_path()
oiio_cmd = [
oiio_tool_path,
"-a", src_path,
"-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

convert_colorspace(
src_path,
dst_path,
config_path,
source_colorspace,
view=view,
display=display,
input_args=["-i:ch=R,G,B"]
)

return dst_path

def create_thumbnail_ffmpeg(self, src_path, dst_path):
self.log.info("outputting {}".format(dst_path))
Expand Down

0 comments on commit f814db2

Please sign in to comment.