From 1cf5e522ba194033763b965baf5e5aaaf8ce18e5 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 11:55:16 +0200 Subject: [PATCH 01/18] added font filepath to settings --- openpype/settings/defaults/project_settings/global.json | 7 ++++++- .../projects_schema/schemas/schema_global_publish.json | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/openpype/settings/defaults/project_settings/global.json b/openpype/settings/defaults/project_settings/global.json index 712ec22cfc..791514c987 100644 --- a/openpype/settings/defaults/project_settings/global.json +++ b/openpype/settings/defaults/project_settings/global.json @@ -87,7 +87,12 @@ ], "x_offset": 5, "y_offset": 5, - "bg_padding": 5 + "bg_padding": 5, + "font_filepath": { + "windows": "", + "darwin": "", + "linux": "" + } }, "profiles": [ { diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json index 62de311024..4abb66e8e6 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json @@ -334,6 +334,13 @@ "type": "number", "key": "bg_padding", "label": "Padding aroung text" + }, + { + "type": "path", + "key": "font_filepath", + "label": "Font file path", + "multipath": false, + "multiplatform": true } ] }, From c218c5e9014e1764876ee45373ad4b1eb983872a Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 12:11:31 +0200 Subject: [PATCH 02/18] changed font loading in otio burnin script --- openpype/scripts/otio_burnin.py | 35 ++++++++++++++------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index 6dcf00e97c..a4b81274c5 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -244,31 +244,26 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins): timecode_text = options.get("timecode") or "" text_for_size += timecode_text + font_path = options.get("font") + if not font_path or not os.path.exists(font_path): + font_path = ffmpeg_burnins.FONT + + options["font"] = font_path + data.update(options) - - os_system = platform.system().lower() - data_font = data.get("font") - if not data_font: - data_font = ( - resources.get_liberation_font_path().replace("\\", "/") - ) - elif isinstance(data_font, dict): - data_font = data_font[os_system] - - if data_font: - data["font"] = data_font - options["font"] = data_font - if ffmpeg_burnins._is_windows(): - data["font"] = ( - data_font - .replace(os.sep, r'\\' + os.sep) - .replace(':', r'\:') - ) - data.update( ffmpeg_burnins._drawtext(align, resolution, text_for_size, options) ) + arg_font_path = font_path + if platform.system().lower() == "windows": + arg_font_path = ( + arg_font_path + .replace(os.sep, r'\\' + os.sep) + .replace(':', r'\:') + ) + data["font"] = arg_font_path + self.filters['drawtext'].append(draw % data) if options.get('bg_color') is not None: From ce94ee37a4116defc55f05daf3dc53cede79798c Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 12:16:47 +0200 Subject: [PATCH 03/18] extracted representation tags to schema --- .../schemas/schema_global_publish.json | 26 ++----------------- .../schemas/schema_representation_tags.json | 26 +++++++++++++++++++ 2 files changed, 28 insertions(+), 24 deletions(-) create mode 100644 openpype/settings/entities/schemas/projects_schema/schemas/schema_representation_tags.json diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json index 4abb66e8e6..330b2d6fa6 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json @@ -101,30 +101,8 @@ "type": "text" }, { - "key": "tags", - "label": "Tags", - "type": "enum", - "multiselection": true, - "enum_items": [ - { - "burnin": "Add burnins" - }, - { - "ftrackreview": "Add to Ftrack" - }, - { - "delete": "Delete output" - }, - { - "slate-frame": "Add slate frame" - }, - { - "no-handles": "Skip handle frames" - }, - { - "sequence": "Output as image sequence" - } - ] + "type": "schema", + "name": "schema_representation_tags" }, { "key": "ffmpeg_args", diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_representation_tags.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_representation_tags.json new file mode 100644 index 0000000000..b65de747e5 --- /dev/null +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_representation_tags.json @@ -0,0 +1,26 @@ +{ + "key": "tags", + "label": "Tags", + "type": "enum", + "multiselection": true, + "enum_items": [ + { + "burnin": "Add burnins" + }, + { + "ftrackreview": "Add to Ftrack" + }, + { + "delete": "Delete output" + }, + { + "slate-frame": "Add slate frame" + }, + { + "no-handles": "Skip handle frames" + }, + { + "sequence": "Output as image sequence" + } + ] +} From 379585672df30ecaed6a6678cd3fce20669f97c4 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 12:17:04 +0200 Subject: [PATCH 04/18] added filtering to extract burnin --- .../defaults/project_settings/global.json | 6 +++++- .../schemas/schema_global_publish.json | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/openpype/settings/defaults/project_settings/global.json b/openpype/settings/defaults/project_settings/global.json index 791514c987..d2213044f2 100644 --- a/openpype/settings/defaults/project_settings/global.json +++ b/openpype/settings/defaults/project_settings/global.json @@ -105,7 +105,11 @@ "TOP_RIGHT": "{anatomy[version]}", "BOTTOM_LEFT": "{username}", "BOTTOM_CENTERED": "{asset}", - "BOTTOM_RIGHT": "{frame_start}-{current_frame}-{frame_end}" + "BOTTOM_RIGHT": "{frame_start}-{current_frame}-{frame_end}", + "filter": { + "families": [], + "tags": [] + } } } } diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json index 330b2d6fa6..2636594fad 100644 --- a/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json +++ b/openpype/settings/entities/schemas/projects_schema/schemas/schema_global_publish.json @@ -385,6 +385,24 @@ "key": "BOTTOM_RIGHT", "label": "BottomRight", "type": "text" + }, + { + "key": "filter", + "label": "Additional filtering", + "type": "dict", + "highlight_content": true, + "children": [ + { + "key": "families", + "label": "Families", + "type": "list", + "object_type": "text" + }, + { + "type": "schema", + "name": "schema_representation_tags" + } + ] } ] } From 13378f315ddead1afb87782e51b42919020f994e Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:14:16 +0200 Subject: [PATCH 05/18] implemented method to get burnin options --- openpype/plugins/publish/extract_burnin.py | 91 +++++++++++++--------- 1 file changed, 56 insertions(+), 35 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 1e805afba7..327009a3dd 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -112,41 +112,7 @@ class ExtractBurnin(openpype.api.Extractor): ).format(host_name, family, task_name, profile)) return - # Prepare burnin options - profile_options = copy.deepcopy(self.default_options) - for key, value in (self.options or {}).items(): - if value is None: - continue - - if key == "bg_color" and len(value) == 4: - bg_red, bg_green, bg_blue, bg_alpha = value - bg_color_hex = "#{0:0>2X}{1:0>2X}{2:0>2X}".format( - bg_red, bg_green, bg_blue - ) - bg_color_alpha = float(bg_alpha) / 255 - profile_options["bg_opacity"] = bg_color_alpha - profile_options["bg_color"] = bg_color_hex - continue - - elif key == "font_color" and len(value) == 4: - fg_red, fg_green, fg_blue, fg_alpha = value - fg_color_hex = "#{0:0>2X}{1:0>2X}{2:0>2X}".format( - fg_red, fg_green, fg_blue - ) - fg_color_alpha = float(fg_alpha) / 255 - profile_options["opacity"] = fg_color_alpha - profile_options["font_color"] = fg_color_hex - continue - - profile_options[key] = value - - # Prepare global burnin values from presets - profile_burnins = {} - for key, value in (self.fields or {}).items(): - key_low = key.lower() - if key_low in self.positions: - if value is not None: - profile_burnins[key_low] = value + profile_options = self._get_burnin_options() # Prepare basic data for processing _burnin_data, _temp_data = self.prepare_basic_data(instance) @@ -326,6 +292,61 @@ class ExtractBurnin(openpype.api.Extractor): if do_decompress and os.path.exists(decompressed_dir): shutil.rmtree(decompressed_dir) + def _get_burnin_options(self): + # Prepare burnin options + burnin_options = copy.deepcopy(self.default_options) + if self.options: + for key, value in self.options.items(): + if value is not None: + burnin_options[key] = copy.deepcopy(value) + + # Convert colors defined as list of numbers RGBA (0-255) + # BG Color + bg_color = burnin_options.get("bg_color") + if bg_color and isinstance(bg_color, list): + bg_red, bg_green, bg_blue, bg_alpha = bg_color + bg_color_hex = "#{0:0>2X}{1:0>2X}{2:0>2X}".format( + bg_red, bg_green, bg_blue + ) + bg_color_alpha = float(bg_alpha) / 255 + burnin_options["bg_opacity"] = bg_color_alpha + burnin_options["bg_color"] = bg_color_hex + + # FG Color + font_color = burnin_options.get("font_color") + if font_color and isinstance(font_color, list): + fg_red, fg_green, fg_blue, fg_alpha = font_color + fg_color_hex = "#{0:0>2X}{1:0>2X}{2:0>2X}".format( + fg_red, fg_green, fg_blue + ) + fg_color_alpha = float(fg_alpha) / 255 + burnin_options["opacity"] = fg_color_alpha + burnin_options["font_color"] = fg_color_hex + + # Define font filepath + # - font filepath may be defined in settings + font_filepath = burnin_options.get("font_filepath") + self.log.info(str(font_filepath)) + if font_filepath and isinstance(font_filepath, dict): + sys_name = platform.system().lower() + font_filepath = font_filepath.get(sys_name) + + self.log.info(str(font_filepath)) + str_type = type("") + if font_filepath and isinstance(font_filepath, str_type): + font_filepath = font_filepath.format(**os.environ) + if not os.path.exists(font_filepath): + font_filepath = None + + self.log.info(str(font_filepath)) + # Use OpenPype default font + if not font_filepath: + font_filepath = openpype.api.resources.get_liberation_font_path() + + burnin_options["font"] = font_filepath + + return burnin_options + def prepare_basic_data(self, instance): """Pick data from instance for processing and for burnin strings. From 4007d9863ab5d7570c47209426bb5243c205fc64 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:14:39 +0200 Subject: [PATCH 06/18] added new default options --- openpype/plugins/publish/extract_burnin.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 327009a3dd..01591f4552 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -49,12 +49,12 @@ class ExtractBurnin(openpype.api.Extractor): ] # Default options for burnins for cases that are not set in presets. default_options = { - "opacity": 1, - "x_offset": 5, - "y_offset": 5, + "font_size": 42, + "font_color": [255, 255, 255, 255], + "bg_color": [0, 0, 0, 127], "bg_padding": 5, - "bg_opacity": 0.5, - "font_size": 42 + "x_offset": 5, + "y_offset": 5 } # Preset attributes From a99c81797d2847368bf4e48f0c6c6124a685893f Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:17:50 +0200 Subject: [PATCH 07/18] burnin defintion do not hav option overrides anymore --- openpype/plugins/publish/extract_burnin.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 01591f4552..c51bdaf724 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -173,15 +173,8 @@ class ExtractBurnin(openpype.api.Extractor): elif "ftrackreview" in new_repre["tags"]: new_repre["tags"].remove("ftrackreview") - burnin_options = copy.deepcopy(profile_options) burnin_values = copy.deepcopy(profile_burnins) - # Options overrides - for key, value in (burnin_def.get("options") or {}).items(): - # Set or override value if is valid - if value is not None: - burnin_options[key] = value - # Burnin values overrides for key, value in burnin_def.items(): key_low = key.lower() @@ -235,7 +228,7 @@ class ExtractBurnin(openpype.api.Extractor): "input": temp_data["full_input_path"], "output": temp_data["full_output_path"], "burnin_data": burnin_data, - "options": burnin_options, + "options": copy.deepcopy(burnin_options), "values": burnin_values, "full_input_path": temp_data["full_input_paths"][0], "first_frame": temp_data["first_frame"] From b62783bd5b9c73bccd0e0341d4522b620babc6ba Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:18:29 +0200 Subject: [PATCH 08/18] faster and readable tags filtering --- openpype/plugins/publish/extract_burnin.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index c51bdaf724..f7aaca3800 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -458,23 +458,15 @@ class ExtractBurnin(openpype.api.Extractor): list: Containg all burnin definitions matching entered tags. """ filtered_burnins = {} - repre_tags_low = [tag.lower() for tag in tags] + repre_tags_low = set(tag.lower() for tag in tags) for filename_suffix, burnin_def in burnin_defs.items(): valid = True - output_filters = burnin_def.get("filter") - if output_filters: + tag_filters = burnin_def["filter"]["tags"] + if tag_filters: # Check tag filters - tag_filters = output_filters.get("tags") - if tag_filters: - tag_filters_low = [tag.lower() for tag in tag_filters] - valid = False - for tag in repre_tags_low: - if tag in tag_filters_low: - valid = True - break + tag_filters_low = set(tag.lower() for tag in tag_filters) - if not valid: - continue + valid = bool(repre_tags_low & tag_filters_low) if valid: filtered_burnins[filename_suffix] = burnin_def From b84041b57da21168375be8dc7e0c27ae900ee2fd Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:19:14 +0200 Subject: [PATCH 09/18] renamed `filter_burnins_by_families` to `filter_burnins_defs` which also check definition values --- openpype/plugins/publish/extract_burnin.py | 66 ++++++++++++++++------ 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index f7aaca3800..2210258509 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -104,7 +104,7 @@ class ExtractBurnin(openpype.api.Extractor): return # Pre-filter burnin definitions by instance families - burnin_defs = self.filter_burnins_by_families(profile, instance) + burnin_defs = self.filter_burnins_defs(profile, instance) if not burnin_defs: self.log.info(( "Skipped instance. Burnin definitions are not set for profile" @@ -742,17 +742,16 @@ class ExtractBurnin(openpype.api.Extractor): final_profile.pop("__value__") return final_profile - def filter_burnins_by_families(self, profile, instance): - """Filter outputs that are not supported for instance families. + def filter_burnins_defs(self, profile, instance): + """Filter outputs by their values from settings. - Output definitions without families filter are marked as valid. + Output definitions with at least one value are marked as valid. Args: profile (dict): Profile from presets matching current context. - families (list): All families of current instance. Returns: - list: Containg all output definitions matching entered families. + list: Containg all valid output definitions. """ filtered_burnin_defs = {} @@ -760,21 +759,52 @@ class ExtractBurnin(openpype.api.Extractor): if not burnin_defs: return filtered_burnin_defs - # Prepare families families = self.families_from_instance(instance) - families = [family.lower() for family in families] + low_families = [family.lower() for family in families] - for filename_suffix, burnin_def in burnin_defs.items(): - burnin_filter = burnin_def.get("filter") - # When filters not set then skip filtering process - if burnin_filter: - families_filters = burnin_filter.get("families") - if not self.families_filter_validation( - families, families_filters - ): - continue + for filename_suffix, orig_burnin_def in burnin_defs.items(): + burnin_def = copy.deepcopy(orig_burnin_def) + def_filter = burnin_def.get("filter", None) or {} + for key in ("families", "tags"): + if key not in def_filter: + def_filter[key] = [] + + families_filters = def_filter["families"] + if not self.families_filter_validation( + low_families, families_filters + ): + self.log.debug(( + "Skipped burnin definition \"{}\". Family" + " fiters ({}) does not match current instance families: {}" + ).format( + filename_suffix, str(families_filters), str(families) + )) + continue + + # Burnin values + burnin_values = {} + for key, value in tuple(burnin_def.items()): + key_low = key.lower() + if key_low in self.positions and value: + burnin_values[key_low] = value + + # Skip processing if burnin values are not set + if not burnin_values: + self.log.warning(( + "Burnin values for Burnin definition \"{}\"" + " are not filled. Definition will be skipped." + " Origin value: {}" + ).format(filename_suffix, str(orig_burnin_def))) + continue + + burnin_values["filter"] = def_filter + + filtered_burnin_defs[filename_suffix] = burnin_values + + self.log.debug(( + "Burnin definition \"{}\" passed first filtering." + ).format(filename_suffix)) - filtered_burnin_defs[filename_suffix] = burnin_def return filtered_burnin_defs def families_filter_validation(self, families, output_families_filter): From 9276f19c9bf24e212f8edf09954f7403a6ed9fc7 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:19:30 +0200 Subject: [PATCH 10/18] fields are not used anymore --- openpype/plugins/publish/extract_burnin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 2210258509..9f82cd24bc 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -60,7 +60,6 @@ class ExtractBurnin(openpype.api.Extractor): # Preset attributes profiles = None options = None - fields = None def process(self, instance): # ffmpeg doesn't support multipart exrs From 206b1559a52f8705fd925ef82d29ce5a193881c3 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:19:56 +0200 Subject: [PATCH 11/18] easier burnin values getter --- openpype/plugins/publish/extract_burnin.py | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 9f82cd24bc..23423ac9e7 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -172,19 +172,11 @@ class ExtractBurnin(openpype.api.Extractor): elif "ftrackreview" in new_repre["tags"]: new_repre["tags"].remove("ftrackreview") - burnin_values = copy.deepcopy(profile_burnins) - - # Burnin values overrides - for key, value in burnin_def.items(): - key_low = key.lower() - if key_low in self.positions: - if value is not None: - # Set or override value if is valid - burnin_values[key_low] = value - - elif key_low in burnin_values: - # Pop key if value is set to None (null in json) - burnin_values.pop(key_low) + burnin_values = {} + for key in self.positions: + value = burnin_def.get(key) + if value: + burnin_values[key] = value # Remove "delete" tag from new representation if "delete" in new_repre["tags"]: From 5df14df898fa2329dd02e362ccf9966f1fc4b5e1 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:20:05 +0200 Subject: [PATCH 12/18] fix variable name --- openpype/plugins/publish/extract_burnin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 23423ac9e7..235d2c8df9 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -111,7 +111,7 @@ class ExtractBurnin(openpype.api.Extractor): ).format(host_name, family, task_name, profile)) return - profile_options = self._get_burnin_options() + burnin_options = self._get_burnin_options() # Prepare basic data for processing _burnin_data, _temp_data = self.prepare_basic_data(instance) @@ -187,7 +187,8 @@ class ExtractBurnin(openpype.api.Extractor): # able have multiple outputs in case of more burnin presets # Join previous "outputName" with filename suffix new_name = "_".join( - [new_repre["outputName"], filename_suffix]) + [new_repre["outputName"], filename_suffix] + ) new_repre["name"] = new_name new_repre["outputName"] = new_name From ed6584146dd7f9de32052de8693bd5977faa1eaa Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 13:20:11 +0200 Subject: [PATCH 13/18] reorganize imports --- openpype/plugins/publish/extract_burnin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 235d2c8df9..563d471323 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -3,18 +3,20 @@ import re import json import copy import tempfile +import platform +import shutil + import clique +import pyblish import openpype import openpype.api -import pyblish from openpype.lib import ( get_pype_execute_args, should_decompress, get_decompress_dir, decompress ) -import shutil class ExtractBurnin(openpype.api.Extractor): From f8f528a42fa8106bb33acb29d11e37ea90c95d31 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 15:48:47 +0200 Subject: [PATCH 14/18] don't use shell=True in extract burnin subprocess --- openpype/plugins/publish/extract_burnin.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 563d471323..49708da506 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -1,5 +1,6 @@ import os import re +import subprocess import json import copy import tempfile @@ -124,11 +125,6 @@ class ExtractBurnin(openpype.api.Extractor): # [pype executable, *pype script, "run"] executable_args = get_pype_execute_args("run", scriptpath) - # Environments for script process - env = os.environ.copy() - # pop PYTHONPATH - env.pop("PYTHONPATH", None) - for idx, repre in enumerate(tuple(instance.data["representations"])): self.log.debug("repre ({}): `{}`".format(idx + 1, repre["name"])) if not self.repres_is_valid(repre): @@ -251,10 +247,16 @@ class ExtractBurnin(openpype.api.Extractor): self.log.debug("Executing: {}".format(" ".join(args))) # Run burnin script - openpype.api.run_subprocess( - args, shell=True, logger=self.log, env=env - ) + process_kwargs = { + "logger": self.log, + "env": {} + } + if platform.system().lower() == "windows": + process_kwargs["creationflags"] = ( + subprocess.CREATE_NO_WINDOW + ) + openpype.api.run_subprocess(args, **process_kwargs) # Remove the temporary json os.remove(temporary_json_filepath) From 2f10c39ea87ba825c177af66c870d0bc264be932 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 15:53:41 +0200 Subject: [PATCH 15/18] removed debug logs --- openpype/plugins/publish/extract_burnin.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index 49708da506..c976bd959e 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -315,19 +315,16 @@ class ExtractBurnin(openpype.api.Extractor): # Define font filepath # - font filepath may be defined in settings font_filepath = burnin_options.get("font_filepath") - self.log.info(str(font_filepath)) if font_filepath and isinstance(font_filepath, dict): sys_name = platform.system().lower() font_filepath = font_filepath.get(sys_name) - self.log.info(str(font_filepath)) str_type = type("") if font_filepath and isinstance(font_filepath, str_type): font_filepath = font_filepath.format(**os.environ) if not os.path.exists(font_filepath): font_filepath = None - self.log.info(str(font_filepath)) # Use OpenPype default font if not font_filepath: font_filepath = openpype.api.resources.get_liberation_font_path() From 371620714ba1fa1e69a4b0a1508b0b5fd379e41a Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 15:53:54 +0200 Subject: [PATCH 16/18] use six module to get string type --- openpype/plugins/publish/extract_burnin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index c976bd959e..c37fa7390a 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -8,6 +8,7 @@ import platform import shutil import clique +import six import pyblish import openpype @@ -319,8 +320,7 @@ class ExtractBurnin(openpype.api.Extractor): sys_name = platform.system().lower() font_filepath = font_filepath.get(sys_name) - str_type = type("") - if font_filepath and isinstance(font_filepath, str_type): + if font_filepath and isinstance(font_filepath, six.string_types): font_filepath = font_filepath.format(**os.environ) if not os.path.exists(font_filepath): font_filepath = None From 73c5a81bb5fc012054dbc2bb6bbbbfb4a378e447 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 16:05:46 +0200 Subject: [PATCH 17/18] fix start frame of output sequence --- openpype/scripts/otio_burnin.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index a4b81274c5..e65d659e32 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -127,11 +127,8 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins): if not streams: streams = _streams(source) - input_args = [] - if first_frame: - input_args.append("-start_number {}".format(first_frame)) - - self.input_args = input_args + self.first_frame = first_frame + self.input_args = [] super().__init__(source, streams) @@ -292,6 +289,15 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins): if self.filter_string: filters = '-vf "{}"'.format(self.filter_string) + if self.first_frame is not None: + start_number_arg = "-start_number {}".format(self.first_frame) + self.input_args.append(start_number_arg) + if "start_number" not in args: + if not args: + args = start_number_arg + else: + args = " ".join((start_number_arg, args)) + input_args = "" if self.input_args: input_args = " {}".format(" ".join(self.input_args)) From 0ea31961e29ec39115d26acb6bed663ca3313a88 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 5 May 2021 16:12:06 +0200 Subject: [PATCH 18/18] removed unused import --- openpype/scripts/otio_burnin.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index e65d659e32..8826f1af0c 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -5,7 +5,6 @@ import subprocess import platform import json import opentimelineio_contrib.adapters.ffmpeg_burnins as ffmpeg_burnins -from openpype.api import resources import openpype.lib