From 76e0be34c8869ecb85833c8064a6b921d6ee9bd8 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 19 May 2021 12:43:33 +0200 Subject: [PATCH 01/10] added schema for bg color in extract review --- .../schemas/schema_global_publish.json | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 0efe3b8fea..6989252826 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 @@ -193,6 +193,20 @@ "minimum": 0, "maximum": 100000 }, + { + "type": "label", + "label": "Background color is used only when input have transparency and Alpha is higher than 0." + }, + { + "type": "schema_template", + "name": "template_rgba_color", + "template_data": [ + { + "label": "Background color", + "name": "bg_color" + } + ] + }, { "key": "letter_box", "label": "Letter box", From 968c8028e607ff779cfad614ce4df977f6074aad Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 19 May 2021 12:44:06 +0200 Subject: [PATCH 02/10] saved default bg color --- openpype/settings/defaults/project_settings/global.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openpype/settings/defaults/project_settings/global.json b/openpype/settings/defaults/project_settings/global.json index 1f54bed03c..6b079e367e 100644 --- a/openpype/settings/defaults/project_settings/global.json +++ b/openpype/settings/defaults/project_settings/global.json @@ -57,6 +57,12 @@ }, "width": 0, "height": 0, + "bg_color": [ + 0, + 0, + 0, + 0 + ], "letter_box": { "enabled": false, "ratio": 0.0, From f249499b5bc10cba85682de5311bdec5fb9ac00f Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 19 May 2021 13:15:53 +0200 Subject: [PATCH 03/10] add bg color to ffmpeg args if is set --- openpype/plugins/publish/extract_review.py | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index 048d16fabb..af30e6534d 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -470,6 +470,33 @@ class ExtractReview(pyblish.api.InstancePlugin): lut_filters = self.lut_filters(new_repre, instance, ffmpeg_input_args) ffmpeg_video_filters.extend(lut_filters) + bg_alpha = 0 + bg_color = output_def.get("bg_color") + if bg_color: + bg_red, bg_green, bg_blue, bg_alpha = bg_color + + if bg_alpha > 0: + if not temp_data["input_allow_bg"]: + self.log.info(( + "Output definition has defined BG color input was" + " resolved as does not support adding BG." + )) + else: + 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 + bg_color_str = "{}@{}".format(bg_color_hex, bg_color_alpha) + + self.log.info("Applying BG color {}".format(bg_color_str)) + ffmpeg_video_filters.extend([ + "split=2[bg][fg]", + "[bg]drawbox=c={}:replace=1:t=fill[bg]".format( + bg_color_str + ), + "[bg][fg]overlay=format=auto" + ]) + # Add argument to override output file ffmpeg_output_args.append("-y") From 4f0f91e9563180496f0316860f5339d9ae57e5c6 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 19 May 2021 14:05:29 +0200 Subject: [PATCH 04/10] defined if input is valid for bg color usage --- openpype/plugins/publish/extract_review.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index af30e6534d..816bcbbc51 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -48,6 +48,8 @@ class ExtractReview(pyblish.api.InstancePlugin): video_exts = ["mov", "mp4"] supported_exts = image_exts + video_exts + alpha_exts = ["exr", "png", "dpx"] + # FFmpeg tools paths ffmpeg_path = get_ffmpeg_tool_path("ffmpeg") @@ -296,6 +298,13 @@ class ExtractReview(pyblish.api.InstancePlugin): ): with_audio = False + input_is_sequence = self.input_is_sequence(repre) + input_allow_bg = False + if input_is_sequence and repre["files"]: + ext = os.path.splitext(repre["files"][0])[1].replace(".", "") + if ext in self.alpha_exts: + input_allow_bg = True + return { "fps": float(instance.data["fps"]), "frame_start": frame_start, @@ -310,7 +319,8 @@ class ExtractReview(pyblish.api.InstancePlugin): "resolution_width": instance.data.get("resolutionWidth"), "resolution_height": instance.data.get("resolutionHeight"), "origin_repre": repre, - "input_is_sequence": self.input_is_sequence(repre), + "input_is_sequence": input_is_sequence, + "input_allow_bg": input_allow_bg, "with_audio": with_audio, "without_handles": without_handles, "handles_are_set": handles_are_set From 19312827f75618975a4053891626e12855f27651 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 19 May 2021 14:05:50 +0200 Subject: [PATCH 05/10] prepend bg color filters before all other filters --- openpype/plugins/publish/extract_review.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index 816bcbbc51..0d97afe3ae 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -499,13 +499,18 @@ class ExtractReview(pyblish.api.InstancePlugin): bg_color_str = "{}@{}".format(bg_color_hex, bg_color_alpha) self.log.info("Applying BG color {}".format(bg_color_str)) - ffmpeg_video_filters.extend([ + color_args = [ "split=2[bg][fg]", "[bg]drawbox=c={}:replace=1:t=fill[bg]".format( bg_color_str ), "[bg][fg]overlay=format=auto" - ]) + ] + # Prepend bg color change before all video filters + # NOTE at the time of creation it is required as video filters + # from settings may affect color of BG (e.g. to grey) + for arg in reversed(color_args): + ffmpeg_video_filters.insert(0, arg) # Add argument to override output file ffmpeg_output_args.append("-y") From d888fcf9849b101d303f049a619f55d257fa7de6 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 19 May 2021 14:22:52 +0200 Subject: [PATCH 06/10] modified comment --- openpype/plugins/publish/extract_review.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/openpype/plugins/publish/extract_review.py b/openpype/plugins/publish/extract_review.py index 0d97afe3ae..7569023e0c 100644 --- a/openpype/plugins/publish/extract_review.py +++ b/openpype/plugins/publish/extract_review.py @@ -508,7 +508,8 @@ class ExtractReview(pyblish.api.InstancePlugin): ] # Prepend bg color change before all video filters # NOTE at the time of creation it is required as video filters - # from settings may affect color of BG (e.g. to grey) + # from settings may affect color of BG + # e.g. `eq` can remove alpha from input for arg in reversed(color_args): ffmpeg_video_filters.insert(0, arg) From 86f7fa9bc58c328fb838ef1205353d6aaeb87fce Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Wed, 19 May 2021 14:30:31 +0200 Subject: [PATCH 07/10] replaced `eq` filter with `apply_trc` argument in defualt settings --- openpype/settings/defaults/project_settings/global.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openpype/settings/defaults/project_settings/global.json b/openpype/settings/defaults/project_settings/global.json index 6b079e367e..d3b8c55d07 100644 --- a/openpype/settings/defaults/project_settings/global.json +++ b/openpype/settings/defaults/project_settings/global.json @@ -37,11 +37,11 @@ "ftrackreview" ], "ffmpeg_args": { - "video_filters": [ - "eq=gamma=2.2" - ], + "video_filters": [], "audio_filters": [], - "input": [], + "input": [ + "-apply_trc gamma22" + ], "output": [ "-pix_fmt yuv420p", "-crf 18", From 805f7e0c96d200058688662600813b92f6986dd6 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 25 May 2021 10:34:50 +0200 Subject: [PATCH 08/10] use new color entity instead of template_rgba_color --- .../schemas/schema_global_publish.json | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) 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 b68a1a68b1..37ec54a1b1 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 @@ -198,14 +198,9 @@ "label": "Background color is used only when input have transparency and Alpha is higher than 0." }, { - "type": "schema_template", - "name": "template_rgba_color", - "template_data": [ - { - "label": "Background color", - "name": "bg_color" - } - ] + "type": "color", + "label": "Background color", + "key": "bg_color" }, { "key": "letter_box", From 7b737f0c94381f34b02b35203d21b86ec81066ed Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 25 May 2021 10:40:46 +0200 Subject: [PATCH 09/10] add color entity for colors in extract burnin --- .../schemas/schema_global_publish.json | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) 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 37ec54a1b1..11b95862fa 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 @@ -289,24 +289,14 @@ "minimum": 0 }, { - "type": "schema_template", - "name": "template_rgba_color", - "template_data": [ - { - "label": "Font Color", - "name": "font_color" - } - ] + "type": "color", + "key": "font_color", + "label": "Font Color" }, { - "type": "schema_template", - "name": "template_rgba_color", - "template_data": [ - { - "label": "Background Color", - "name": "bg_color" - } - ] + "type": "color", + "key": "bg_color", + "label": "Background Color" }, { "type": "number", From a559068abf4e5fc1f4256ec33f75f6a827d4b4a5 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Tue, 25 May 2021 10:41:07 +0200 Subject: [PATCH 10/10] removed unused template_rgba_color --- .../schemas/template_rgba_color.json | 33 ------------------- 1 file changed, 33 deletions(-) delete mode 100644 openpype/settings/entities/schemas/projects_schema/schemas/template_rgba_color.json diff --git a/openpype/settings/entities/schemas/projects_schema/schemas/template_rgba_color.json b/openpype/settings/entities/schemas/projects_schema/schemas/template_rgba_color.json deleted file mode 100644 index ffe530175a..0000000000 --- a/openpype/settings/entities/schemas/projects_schema/schemas/template_rgba_color.json +++ /dev/null @@ -1,33 +0,0 @@ -[ - { - "type": "list-strict", - "key": "{name}", - "label": "{label}", - "object_types": [ - { - "label": "R", - "type": "number", - "minimum": 0, - "maximum": 255 - }, - { - "label": "G", - "type": "number", - "minimum": 0, - "maximum": 255 - }, - { - "label": "B", - "type": "number", - "minimum": 0, - "maximum": 255 - }, - { - "label": "A", - "type": "number", - "minimum": 0, - "maximum": 255 - } - ] - } -]