mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 00:44:52 +01:00
flame: update export plugin with more dynamic preset path abstraction
This commit is contained in:
parent
0e96a2e3b1
commit
183acf4bd3
1 changed files with 96 additions and 59 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
from copy import deepcopy
|
||||
import pyblish.api
|
||||
import openpype.api
|
||||
from openpype.hosts.flame import api as opfapi
|
||||
|
|
@ -14,25 +15,29 @@ class ExtractSubsetResources(openpype.api.Extractor):
|
|||
families = ["clip"]
|
||||
hosts = ["flame"]
|
||||
|
||||
# plugin defaults
|
||||
default_presets = {
|
||||
"thumbnail": {
|
||||
"ext": "jpg",
|
||||
"xmlPresetFile": "Jpeg (8-bit).xml",
|
||||
"xmlPresetDir": "",
|
||||
"representationTags": ["thumbnail"]
|
||||
},
|
||||
"ftrackpreview": {
|
||||
"ext": "mov",
|
||||
"xmlPresetFile": "Apple iPad (1920x1080).xml",
|
||||
"xmlPresetDir": "",
|
||||
"representationTags": [
|
||||
"review",
|
||||
"delete"
|
||||
]
|
||||
}
|
||||
}
|
||||
# hide publisher during exporting
|
||||
hide_ui_on_process = True
|
||||
|
||||
export_presets_mapping = {
|
||||
"thumbnail": {
|
||||
"ext": "jpg",
|
||||
"uniqueName": "thumbnail"
|
||||
},
|
||||
"OpenEXR (16-bit fp DWAA)_custom": {
|
||||
"ext": "exr",
|
||||
"preset_type": "file_sequence",
|
||||
"uniqueName": "exr16fpdwaa"
|
||||
},
|
||||
"QuickTime (H.264 1080p 8Mbits)_custom": {
|
||||
"ext": "mov",
|
||||
"preset_type": "movie_file",
|
||||
"uniqueName": "ftrackpreview"
|
||||
}
|
||||
}
|
||||
# settings
|
||||
export_presets_mapping = {}
|
||||
|
||||
def process(self, instance):
|
||||
# create representation data
|
||||
|
|
@ -53,54 +58,86 @@ class ExtractSubsetResources(openpype.api.Extractor):
|
|||
|
||||
staging_dir = self.staging_dir(instance)
|
||||
|
||||
# loop all preset names and
|
||||
for preset_name, preset_config in self.export_presets_mapping.items():
|
||||
kwargs = {}
|
||||
unique_name = preset_config["uniqueName"]
|
||||
preset_type = None
|
||||
# add default preset type for thumbnail and reviewable video
|
||||
# update them with settings and overide in case the same
|
||||
# are found in there
|
||||
export_presets = deepcopy(self.default_presets)
|
||||
export_presets.update(self.export_presets_mapping)
|
||||
|
||||
# define kwargs based on preset type
|
||||
if "thumbnail" in preset_name:
|
||||
kwargs["thumb_frame_number"] = in_mark + (
|
||||
source_duration_handles / 2)
|
||||
else:
|
||||
preset_type = preset_config["preset_type"]
|
||||
kwargs.update({
|
||||
"in_mark": in_mark,
|
||||
"out_mark": out_mark,
|
||||
"export_type": preset_type
|
||||
})
|
||||
# with maintained duplication loop all presets
|
||||
with opfapi.maintained_object_duplication(clip) as duplclip:
|
||||
# loop all preset names and
|
||||
for unique_name, preset_config in export_presets.items():
|
||||
kwargs = {}
|
||||
preset_file = preset_config["xmlPresetFile"]
|
||||
preset_dir = preset_config["xmlPresetDir"]
|
||||
|
||||
export_dir_path = os.path.join(
|
||||
staging_dir, unique_name
|
||||
)
|
||||
os.makedirs(export_dir_path)
|
||||
# validate xml preset file is filled
|
||||
if preset_file == "":
|
||||
raise ValueError(
|
||||
("Check Settings for {} preset: "
|
||||
"`XML preset file` is not filled").format(
|
||||
unique_name)
|
||||
)
|
||||
|
||||
# export
|
||||
opfapi.export_clip(
|
||||
export_dir_path, clip, preset_name, **kwargs)
|
||||
# resolve xml preset dir if not filled
|
||||
if preset_dir == "":
|
||||
preset_dir = opfapi.get_preset_path_by_xml_name(
|
||||
preset_file)
|
||||
|
||||
# create representation data
|
||||
representation_data = {
|
||||
'name': unique_name,
|
||||
'ext': preset_config["ext"],
|
||||
"stagingDir": export_dir_path,
|
||||
}
|
||||
if not preset_dir:
|
||||
raise ValueError(
|
||||
("Check Settings for {} preset: "
|
||||
"`XML preset file` {} is not found").format(
|
||||
unique_name, preset_file)
|
||||
)
|
||||
|
||||
files = os.listdir(export_dir_path)
|
||||
# create preset path
|
||||
preset_path = os.path.join(
|
||||
preset_dir, preset_file
|
||||
)
|
||||
|
||||
# add files to represetation but add
|
||||
# imagesequence as list
|
||||
if (
|
||||
preset_type
|
||||
and preset_type == "movie_file"
|
||||
or preset_name == "thumbnail"
|
||||
):
|
||||
representation_data["files"] = files.pop()
|
||||
else:
|
||||
representation_data["files"] = files
|
||||
# define kwargs based on preset type
|
||||
if "thumbnail" in unique_name:
|
||||
kwargs["thumb_frame_number"] = in_mark + (
|
||||
source_duration_handles / 2)
|
||||
else:
|
||||
kwargs.update({
|
||||
"in_mark": in_mark,
|
||||
"out_mark": out_mark
|
||||
})
|
||||
|
||||
instance.data["representations"].append(representation_data)
|
||||
export_dir_path = os.path.join(
|
||||
staging_dir, unique_name
|
||||
)
|
||||
os.makedirs(export_dir_path)
|
||||
|
||||
self.log.info("Added representation: {}".format(
|
||||
representation_data))
|
||||
# export
|
||||
opfapi.export_clip(
|
||||
export_dir_path, duplclip, preset_path, **kwargs)
|
||||
|
||||
# create representation data
|
||||
representation_data = {
|
||||
"name": unique_name,
|
||||
"outputName": unique_name,
|
||||
"ext": preset_config["ext"],
|
||||
"stagingDir": export_dir_path,
|
||||
"tags": preset_config["representationTags"]
|
||||
}
|
||||
|
||||
files = os.listdir(export_dir_path)
|
||||
|
||||
# add files to represetation but add
|
||||
# imagesequence as list
|
||||
if (
|
||||
"movie_file" in preset_path
|
||||
or unique_name == "thumbnail"
|
||||
):
|
||||
representation_data["files"] = files.pop()
|
||||
else:
|
||||
representation_data["files"] = files
|
||||
|
||||
instance.data["representations"].append(representation_data)
|
||||
|
||||
self.log.info("Added representation: {}".format(
|
||||
representation_data))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue