Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtractOIIOTranscode: Log warning instead of raise error if media can't be transcoded due to unknown RGBA channels #988

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion client/ayon_core/lib/transcoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@
}


class UnknownRGBAChannelsError(ValueError):
"""Raised when we can't find RGB channels for conversion in input media."""
pass


def get_transcode_temp_directory():
"""Creates temporary folder for transcoding.

Expand Down Expand Up @@ -1427,7 +1432,7 @@ def get_oiio_input_and_channel_args(oiio_input_info, alpha_default=None):
review_channels = get_convert_rgb_channels(channel_names)

if review_channels is None:
raise ValueError(
raise UnknownRGBAChannelsError(
"Couldn't find channels that can be used for conversion."
)

Expand Down
56 changes: 37 additions & 19 deletions client/ayon_core/plugins/publish/extract_color_transcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
)

from ayon_core.lib.transcoding import (
UnknownRGBAChannelsError,
convert_colorspace,
get_transcode_temp_directory,
)
Expand Down Expand Up @@ -99,19 +100,26 @@ def process(self, instance):
self.log.warning("Config file doesn't exist, skipping")
continue

# Get representation files to convert
if isinstance(repre["files"], list):
repre_files_to_convert = copy.deepcopy(repre["files"])
else:
repre_files_to_convert = [repre["files"]]
repre_files_to_convert = self._translate_to_sequence(
repre_files_to_convert)

# Process each output definition
for output_def in profile_output_defs:
# Local copy to avoid accidental mutable changes
files_to_convert = list(repre_files_to_convert)

output_name = output_def["name"]
new_repre = copy.deepcopy(repre)

original_staging_dir = new_repre["stagingDir"]
new_staging_dir = get_transcode_temp_directory()
new_repre["stagingDir"] = new_staging_dir

if isinstance(new_repre["files"], list):
files_to_convert = copy.deepcopy(new_repre["files"])
else:
files_to_convert = [new_repre["files"]]

output_extension = output_def["extension"]
output_extension = output_extension.replace('.', '')
self._rename_in_representation(new_repre,
Expand All @@ -120,7 +128,6 @@ def process(self, instance):
output_extension)

transcoding_type = output_def["transcoding_type"]

target_colorspace = view = display = None
# NOTE: we use colorspace_data as the fallback values for
# the target colorspace.
Expand Down Expand Up @@ -152,25 +159,36 @@ def process(self, instance):
additional_command_args = (output_def["oiiotool_args"]
["additional_command_args"])

files_to_convert = self._translate_to_sequence(
files_to_convert)
unknown_rgba_channels = False
for file_name in files_to_convert:
input_path = os.path.join(original_staging_dir,
file_name)
output_path = self._get_output_file_path(input_path,
new_staging_dir,
output_extension)
convert_colorspace(
input_path,
output_path,
config_path,
source_colorspace,
target_colorspace,
view,
display,
additional_command_args,
self.log
)
try:
convert_colorspace(
input_path,
output_path,
config_path,
source_colorspace,
target_colorspace,
view,
display,
additional_command_args,
self.log
)
except UnknownRGBAChannelsError:
unknown_rgba_channels = True
self.log.error(
"Skipping OIIO Transcode. Unknown RGBA channels"
f" for colorspace conversion in file: {input_path}"
)
break

if unknown_rgba_channels:
# Stop processing this representation
break

# cleanup temporary transcoded files
for file_name in new_repre["files"]:
Expand Down
Loading