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

Nuke: Multiple format supports for ExtractReviewDataMov #5623

Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c03326f
Jakub's comment on the review plugin
moonyuet Sep 19, 2023
e0fba97
hound
moonyuet Sep 19, 2023
e61515d
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
jakubjezek001 Sep 21, 2023
174ef45
jakub's comment on apply_settings and fix the bug of not being extrac…
moonyuet Sep 22, 2023
98065e0
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
moonyuet Sep 22, 2023
dd2255f
jakub's comment
moonyuet Sep 22, 2023
84e914d
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
moonyuet Sep 22, 2023
d744a48
edit the settings where deprecated_setting used when it enabled; curr…
moonyuet Sep 22, 2023
21d547a
introduce the function for checking the filename to see if it consist…
moonyuet Sep 24, 2023
6f858a8
hound
moonyuet Sep 24, 2023
cf56c4d
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
moonyuet Sep 24, 2023
5f7f4f0
fix the slate in
moonyuet Sep 25, 2023
b749cbf
resolve conflict
moonyuet Sep 25, 2023
41e81ef
rename the function and the elaborate the docstring
moonyuet Sep 25, 2023
22ce181
make sure the deprecated setting used when it enabled while the curre…
moonyuet Sep 25, 2023
3da4bac
typo in lib
moonyuet Sep 25, 2023
8b76238
fixing get_head_filename_without_hashes not being able to get multipl…
moonyuet Sep 25, 2023
e2509a9
hound
moonyuet Sep 25, 2023
ed18c90
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
moonyuet Sep 25, 2023
0c62e19
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
moonyuet Sep 25, 2023
0595afe
add % check on the fhead in the lib.py
moonyuet Sep 25, 2023
65bfe02
transform the files with frame hashes to the list of filenames when p…
moonyuet Sep 25, 2023
9ffc657
Merge branches 'enhancement/OP-6451_Nuke---ExctractReviewDataMov-plug…
moonyuet Sep 26, 2023
6deb933
fix the typo of rstrip
moonyuet Sep 27, 2023
ebdcc49
implement more concise function for getting filenames with hashes
moonyuet Sep 27, 2023
abef01c
edit docstring
moonyuet Sep 27, 2023
e493886
improve docstring on lib.py and add comment on the condition of setti…
moonyuet Sep 27, 2023
973e480
make sure not using .replace
moonyuet Sep 27, 2023
356f05f
docstring tweaks
moonyuet Sep 28, 2023
6c1e066
Rename ExtractReviewDataBakingStreams to ExtractReviewIntermediate
moonyuet Sep 28, 2023
ef12a52
plural form for extract_review_intermediate
moonyuet Sep 28, 2023
f45552f
label tweak
moonyuet Sep 28, 2023
f57c1eb
edit docsting and rename BakingStreamModel as IntermediateOutputModel
moonyuet Sep 28, 2023
a6522b3
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
moonyuet Sep 29, 2023
bc0f95d
Merge branch 'develop' into enhancement/OP-6451_Nuke---ExctractReview…
moonyuet Sep 29, 2023
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
57 changes: 57 additions & 0 deletions openpype/hosts/nuke/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3423,3 +3423,60 @@ def create_viewer_profile_string(viewer, display=None, path_like=False):
if path_like:
return "{}/{}".format(display, viewer)
return "{} ({})".format(viewer, display)

jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved

def get_head_filename_without_hashes(original_path, name):
"""Function to get the renamed head filename without frame hashes
To avoid the system being confused on finding the filename with
frame hashes if the head of the filename has the hashed symbol

Args:
original_path (str): the filename with frame hashes
e.g. "renderCompositingMain.####.exr"
name (str): the name of the tags
e.g. "baking"

Returns:
filename: the renamed filename with the tag
e.g. "renderCompositingMain.baking.####.exr"
"""
filename = os.path.basename(original_path)
fhead = os.path.splitext(filename)[0].strip(".")
if "#" in fhead:
fhead = re.sub("#+", "", fhead).rstrip(".")
elif "%" in fhead:
# use regex to convert %04d to {:0>4}
padding = re.search("%(\\d)+d", fhead)
padding = padding.group(1) if padding else 1
fhead = re.sub(
"%.*d",
"{{:0>{}}}".format(padding),
fhead
).rstip(".")
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
new_fhead = "{}.{}".format(fhead, name)
filename = filename.replace(fhead, new_fhead)
return filename


def get_filenames_without_hash(filename, frame_start, frame_end):
"""Get filenames without frame hash
i.e. "renderCompositingMain.baking.0001.exr"

Args:
filename (str): filename with frame hash
frame_start (str): start of the frame
frame_end (str): end of the frame

Returns:
filenames(list): list of filename
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
"""
filenames = []
for frame in range(int(frame_start), (int(frame_end) + 1)):
if "#" in filename:
# use regex to convert #### to {:0>4}
def replace(match):
return "{{:0>{}}}".format(len(match.group()))
filename_without_hashes = re.sub("#+", replace, filename)
new_filename = filename_without_hashes.format(frame)
filenames.append(new_filename)
return filenames
20 changes: 18 additions & 2 deletions openpype/hosts/nuke/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
CreatedInstance,
get_current_task_name
)
from openpype.lib.transcoding import (
VIDEO_EXTENSIONS
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
)
from .lib import (
INSTANCE_DATA_KNOB,
Knobby,
Expand All @@ -35,7 +38,9 @@
get_node_data,
get_view_process_node,
get_viewer_config_from_string,
deprecated
deprecated,
get_head_filename_without_hashes,
get_filenames_without_hash
)
from .pipeline import (
list_instances,
Expand Down Expand Up @@ -634,6 +639,10 @@ def get_representation_data(
"frameStart": self.first_frame,
"frameEnd": self.last_frame,
})
if ".{}".format(self.ext) not in VIDEO_EXTENSIONS:
filenames = get_filenames_without_hash(
self.file, self.first_frame, self.last_frame)
repre["files"] = filenames

if self.multiple_presets:
repre["outputName"] = self.name
Expand Down Expand Up @@ -808,6 +817,14 @@ def __init__(self,
self.log.info("File info was set...")

self.file = self.fhead + self.name + ".{}".format(self.ext)
if ".{}".format(self.ext) not in VIDEO_EXTENSIONS:
filename = get_head_filename_without_hashes(
self.path_in, self.name)
self.file = filename
if ".{}".format(self.ext) not in self.file:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that we're always expecting the file should END with the extension - right? So we should still change the extension if the extension .exr for the filename was originally hello.exr.0001.png.

This should've been:

if not self.file.endswith(".{}".format(ext)):
    # Swap the extension
    ...

original_ext = os.path.splitext(filename)[-1].strip(".") # noqa
self.file = filename.replace(original_ext, ext)
moonyuet marked this conversation as resolved.
Show resolved Hide resolved

self.path = os.path.join(
self.staging_dir, self.file).replace("\\", "/")

Expand Down Expand Up @@ -933,7 +950,6 @@ def generate_mov(self, farm=False, **kwargs):
self.log.debug("Path: {}".format(self.path))
write_node["file"].setValue(str(self.path))
write_node["file_type"].setValue(str(self.ext))

# Knobs `meta_codec` and `mov64_codec` are not available on centos.
# TODO shouldn't this come from settings on outputs?
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
from openpype.hosts.nuke.api.lib import maintained_selection


class ExtractReviewDataMov(publish.Extractor):
class ExtractReviewDataBakingStreams(publish.Extractor):
"""Extracts movie and thumbnail with baked in luts
moonyuet marked this conversation as resolved.
Show resolved Hide resolved

must be run after extract_render_local.py

"""

order = pyblish.api.ExtractorOrder + 0.01
label = "Extract Review Data Mov"
label = "Extract Review Data Baking Streams"
moonyuet marked this conversation as resolved.
Show resolved Hide resolved

families = ["review"]
hosts = ["nuke"]
Expand All @@ -25,6 +25,22 @@ class ExtractReviewDataMov(publish.Extractor):
viewer_lut_raw = None
outputs = {}

@classmethod
def apply_settings(cls, project_settings):
"""just in case there are some old presets
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
in deprecated ExtractReviewDataMov Plugins
"""
nuke_publish = project_settings["nuke"]["publish"]
deprecated_setting = nuke_publish["ExtractReviewDataMov"]
current_setting = nuke_publish["ExtractReviewDataBakingStreams"]
if not deprecated_setting["enabled"]:
if current_setting["enabled"]:
cls.viewer_lut_raw = current_setting["viewer_lut_raw"]
cls.outputs = current_setting["outputs"]
else:
cls.viewer_lut_raw = deprecated_setting["viewer_lut_raw"]
cls.outputs = deprecated_setting["outputs"]
moonyuet marked this conversation as resolved.
Show resolved Hide resolved

def process(self, instance):
families = set(instance.data["families"])

Expand Down
22 changes: 20 additions & 2 deletions openpype/settings/ayon_settings.py
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,19 @@ def _convert_nuke_project_settings(ayon_settings, output):
)

new_review_data_outputs = {}
for item in ayon_publish["ExtractReviewDataMov"]["outputs"]:
outputs_settings = None
# just in case that the users having old presets in outputs setting
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
deprecrated_review_settings = ayon_publish["ExtractReviewDataMov"]
current_review_settings = (
ayon_publish["ExtractReviewDataBakingStreams"]
)
if not deprecrated_review_settings["enabled"]:
if current_review_settings["enabled"]:
outputs_settings = current_review_settings["outputs"]
else:
outputs_settings = deprecrated_review_settings["outputs"]
moonyuet marked this conversation as resolved.
Show resolved Hide resolved

for item in outputs_settings:
item_filter = item["filter"]
if "product_names" in item_filter:
item_filter["subsets"] = item_filter.pop("product_names")
Expand All @@ -767,7 +779,13 @@ def _convert_nuke_project_settings(ayon_settings, output):

name = item.pop("name")
new_review_data_outputs[name] = item
ayon_publish["ExtractReviewDataMov"]["outputs"] = new_review_data_outputs

if deprecrated_review_settings["outputs"] == (
current_review_settings["outputs"]
):
current_review_settings["outputs"] = new_review_data_outputs
moonyuet marked this conversation as resolved.
Show resolved Hide resolved
else:
deprecrated_review_settings["outputs"] = new_review_data_outputs

collect_instance_data = ayon_publish["CollectInstanceData"]
if "sync_workfile_version_on_product_types" in collect_instance_data:
Expand Down
54 changes: 54 additions & 0 deletions openpype/settings/defaults/project_settings/nuke.json
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,60 @@
}
}
},
"ExtractReviewDataBakingStreams": {
"enabled": true,
"viewer_lut_raw": false,
"outputs": {
"baking": {
"filter": {
"task_types": [],
"families": [],
"subsets": []
},
"read_raw": false,
"viewer_process_override": "",
"bake_viewer_process": true,
"bake_viewer_input_process": true,
"reformat_nodes_config": {
"enabled": false,
"reposition_nodes": [
{
"node_class": "Reformat",
"knobs": [
{
"type": "text",
"name": "type",
"value": "to format"
},
{
"type": "text",
"name": "format",
"value": "HD_1080"
},
{
"type": "text",
"name": "filter",
"value": "Lanczos6"
},
{
"type": "bool",
"name": "black_outside",
"value": true
},
{
"type": "bool",
"name": "pbb",
"value": false
}
]
}
]
},
"extension": "mov",
"add_custom_tags": []
}
}
},
"ExtractSlateFrame": {
"viewer_lut_raw": false,
"key_value_mapping": {
Expand Down
Loading