mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge branch 'feature/OP-4643_color-v3-global-oiio-transcoder-exctractor-plugin' into enchancement/OP-2630_acescg_maya
This commit is contained in:
commit
a1e026ecea
4 changed files with 65 additions and 18 deletions
|
|
@ -1054,8 +1054,11 @@ def convert_colorspace(
|
|||
Args:
|
||||
input_path (str): Path that should be converted. It is expected that
|
||||
contains single file or image sequence of same type
|
||||
(sequence in format 'file.FRAMESTART-FRAMEEND#.exr', see oiio docs)
|
||||
(sequence in format 'file.FRAMESTART-FRAMEEND#.ext', see oiio docs,
|
||||
eg `big.1-3#.tif`)
|
||||
output_path (str): Path to output filename.
|
||||
(must follow format of 'input_path', eg. single file or
|
||||
sequence in 'file.FRAMESTART-FRAMEEND#.ext', `output.1-3#.tif`)
|
||||
config_path (str): path to OCIO config file
|
||||
source_colorspace (str): ocio valid color space of source files
|
||||
target_colorspace (str): ocio valid target color space
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ oauth_config:
|
|||
- chat:write.public
|
||||
- files:write
|
||||
- channels:read
|
||||
- users:read
|
||||
- usergroups:read
|
||||
settings:
|
||||
org_deploy_enabled: false
|
||||
socket_mode_enabled: false
|
||||
|
|
|
|||
|
|
@ -32,6 +32,25 @@ class ExtractOIIOTranscode(publish.Extractor):
|
|||
- task types
|
||||
- task names
|
||||
- subset names
|
||||
|
||||
Can produce one or more representations (with different extensions) based
|
||||
on output definition in format:
|
||||
"output_name: {
|
||||
"extension": "png",
|
||||
"colorspace": "ACES - ACEScg",
|
||||
"display": "",
|
||||
"view": "",
|
||||
"tags": [],
|
||||
"custom_tags": []
|
||||
}
|
||||
|
||||
If 'extension' is empty original representation extension is used.
|
||||
'output_name' will be used as name of new representation. In case of value
|
||||
'passthrough' name of original representation will be used.
|
||||
|
||||
'colorspace' denotes target colorspace to be transcoded into. Could be
|
||||
empty if transcoding should be only into display and viewer colorspace.
|
||||
(In that case both 'display' and 'view' must be filled.)
|
||||
"""
|
||||
|
||||
label = "Transcode color spaces"
|
||||
|
|
@ -70,6 +89,7 @@ class ExtractOIIOTranscode(publish.Extractor):
|
|||
continue
|
||||
|
||||
added_representations = False
|
||||
added_review = False
|
||||
|
||||
colorspace_data = repre["colorspaceData"]
|
||||
source_colorspace = colorspace_data["colorspace"]
|
||||
|
|
@ -78,7 +98,7 @@ class ExtractOIIOTranscode(publish.Extractor):
|
|||
self.log.warning("Config file doesn't exist, skipping")
|
||||
continue
|
||||
|
||||
for _, output_def in profile.get("outputs", {}).items():
|
||||
for output_name, output_def in profile.get("outputs", {}).items():
|
||||
new_repre = copy.deepcopy(repre)
|
||||
|
||||
original_staging_dir = new_repre["stagingDir"]
|
||||
|
|
@ -92,10 +112,10 @@ class ExtractOIIOTranscode(publish.Extractor):
|
|||
|
||||
output_extension = output_def["extension"]
|
||||
output_extension = output_extension.replace('.', '')
|
||||
if output_extension:
|
||||
self._rename_in_representation(new_repre,
|
||||
files_to_convert,
|
||||
output_extension)
|
||||
self._rename_in_representation(new_repre,
|
||||
files_to_convert,
|
||||
output_name,
|
||||
output_extension)
|
||||
|
||||
target_colorspace = output_def["colorspace"]
|
||||
view = output_def["view"] or colorspace_data.get("view")
|
||||
|
|
@ -147,17 +167,38 @@ class ExtractOIIOTranscode(publish.Extractor):
|
|||
if tag not in new_repre["tags"]:
|
||||
new_repre["tags"].append(tag)
|
||||
|
||||
if tag == "review":
|
||||
added_review = True
|
||||
|
||||
instance.data["representations"].append(new_repre)
|
||||
added_representations = True
|
||||
|
||||
if added_representations:
|
||||
self._mark_original_repre_for_deletion(repre, profile)
|
||||
self._mark_original_repre_for_deletion(repre, profile,
|
||||
added_review)
|
||||
|
||||
for repre in tuple(instance.data["representations"]):
|
||||
tags = repre.get("tags") or []
|
||||
if "delete" in tags and "thumbnail" not in tags:
|
||||
instance.data["representations"].remove(repre)
|
||||
|
||||
def _rename_in_representation(self, new_repre, files_to_convert,
|
||||
output_extension):
|
||||
"""Replace old extension with new one everywhere in representation."""
|
||||
if new_repre["name"] == new_repre["ext"]:
|
||||
new_repre["name"] = output_extension
|
||||
output_name, output_extension):
|
||||
"""Replace old extension with new one everywhere in representation.
|
||||
|
||||
Args:
|
||||
new_repre (dict)
|
||||
files_to_convert (list): of filenames from repre["files"],
|
||||
standardized to always list
|
||||
output_name (str): key of output definition from Settings,
|
||||
if "<passthrough>" token used, keep original repre name
|
||||
output_extension (str): extension from output definition
|
||||
"""
|
||||
if output_name != "passthrough":
|
||||
new_repre["name"] = output_name
|
||||
if not output_extension:
|
||||
return
|
||||
|
||||
new_repre["ext"] = output_extension
|
||||
|
||||
renamed_files = []
|
||||
|
|
@ -269,15 +310,16 @@ class ExtractOIIOTranscode(publish.Extractor):
|
|||
|
||||
return True
|
||||
|
||||
def _mark_original_repre_for_deletion(self, repre, profile):
|
||||
def _mark_original_repre_for_deletion(self, repre, profile, added_review):
|
||||
"""If new transcoded representation created, delete old."""
|
||||
if not repre.get("tags"):
|
||||
repre["tags"] = []
|
||||
|
||||
delete_original = profile["delete_original"]
|
||||
|
||||
if delete_original:
|
||||
if not repre.get("tags"):
|
||||
repre["tags"] = []
|
||||
|
||||
if "review" in repre["tags"]:
|
||||
repre["tags"].remove("review")
|
||||
if "delete" not in repre["tags"]:
|
||||
repre["tags"].append("delete")
|
||||
|
||||
if added_review and "review" in repre["tags"]:
|
||||
repre["tags"].remove("review")
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@
|
|||
"children": [
|
||||
{
|
||||
"type": "label",
|
||||
"label": "Configure output format(s) and color spaces for matching representations. Empty 'Output extension' denotes keeping source extension."
|
||||
"label": "Configure Output Definition(s) for new representation(s). \nEmpty 'Extension' denotes keeping source extension. \nName(key) of output definition will be used as new representation name \nunless 'passthrough' value is used to keep existing name. \nFill either 'Colorspace' (for target colorspace) or \nboth 'Display' and 'View' (for display and viewer colorspaces)."
|
||||
},
|
||||
{
|
||||
"type": "boolean",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue