From 00f2e16dca2cb37a53a4a6b3096c0f11142a9b66 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Sun, 26 Feb 2023 10:23:39 +0000 Subject: [PATCH 01/17] Static implementation. --- openpype/hosts/maya/plugins/publish/collect_review.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/openpype/hosts/maya/plugins/publish/collect_review.py b/openpype/hosts/maya/plugins/publish/collect_review.py index eb872c2935..c76d4bae97 100644 --- a/openpype/hosts/maya/plugins/publish/collect_review.py +++ b/openpype/hosts/maya/plugins/publish/collect_review.py @@ -139,3 +139,13 @@ class CollectReview(pyblish.api.InstancePlugin): "filename": node.filename.get() } ) + + # Collect focal length. + data = { + "cameraFocalLength": cmds.getAttr(camera + ".focalLength") + } + + try: + instance.data["customData"].update(data) + except KeyError: + instance.data["customData"] = data From e9eb09e100d990e5a6d8648ff32df0d3e7ec4969 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 12:58:33 +0000 Subject: [PATCH 02/17] Initial working version --- .../maya/plugins/publish/collect_review.py | 23 +++-- openpype/lib/execute.py | 7 ++ openpype/plugins/publish/extract_burnin.py | 4 + openpype/scripts/otio_burnin.py | 87 +++++++++++++++++-- 4 files changed, 109 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/collect_review.py b/openpype/hosts/maya/plugins/publish/collect_review.py index 80fd5b0dbd..3d3ee09eed 100644 --- a/openpype/hosts/maya/plugins/publish/collect_review.py +++ b/openpype/hosts/maya/plugins/publish/collect_review.py @@ -146,11 +146,24 @@ class CollectReview(pyblish.api.InstancePlugin): ) # Collect focal length. - data = { - "cameraFocalLength": cmds.getAttr(camera + ".focalLength") - } + #Refactor to lib or use available lib method. + plug = "{0}.focalLength".format(camera) + focal_length = None + if not cmds.listConnections(plug, destination=False, source=True): + # Static. + focal_length = cmds.getAttr(plug) + else: + # Dynamic. + start = instance.data["frameStart"] + end = instance.data["frameEnd"] + 1 + focal_length = [ + cmds.getAttr(plug, time=t) for t in range(int(start), int(end)) + ] + + key = "focalLength" + instance.data[key] = focal_length try: - instance.data["customData"].update(data) + instance.data["burninDataMembers"].append(key) except KeyError: - instance.data["customData"] = data + instance.data["burninDataMembers"] = [key] diff --git a/openpype/lib/execute.py b/openpype/lib/execute.py index 759a4db0cb..5ba62f177f 100644 --- a/openpype/lib/execute.py +++ b/openpype/lib/execute.py @@ -8,6 +8,8 @@ import tempfile from .log import Logger from .vendor_bin_utils import find_executable +from .openpype_version import is_running_from_build + # MSDN process creation flag (Windows only) CREATE_NO_WINDOW = 0x08000000 @@ -196,6 +198,11 @@ def run_openpype_process(*args, **kwargs): # Skip envs that can affect OpenPype process # - fill more if you find more env = clean_envs_for_openpype_process(os.environ) + + # Add OpenPype version if we are running from build. + if not is_running_from_build(): + env.pop("OPENPYPE_VERSION", None) + return run_subprocess(args, env=env, **kwargs) diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index f113e61bb0..de876c8486 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -254,6 +254,10 @@ class ExtractBurnin(publish.Extractor): # Add context data burnin_data. burnin_data["custom"] = custom_data + # Add data members. + for key in instance.data.get("burninDataMembers", []): + burnin_data[key] = instance.data[key] + # Add source camera name to burnin data camera_name = repre.get("camera_name") if camera_name: diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index cb4646c099..bb7a208103 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -4,8 +4,10 @@ import re import subprocess import platform import json -import opentimelineio_contrib.adapters.ffmpeg_burnins as ffmpeg_burnins +import tempfile +from string import Formatter +import opentimelineio_contrib.adapters.ffmpeg_burnins as ffmpeg_burnins from openpype.lib import ( get_ffmpeg_tool_path, get_ffmpeg_codec_args, @@ -23,7 +25,7 @@ FFMPEG = ( ).format(ffmpeg_path) DRAWTEXT = ( - "drawtext=fontfile='%(font)s':text=\\'%(text)s\\':" + "drawtext@'%(label)s'=fontfile='%(font)s':text=\\'%(text)s\\':" "x=%(x)s:y=%(y)s:fontcolor=%(color)s@%(opacity).1f:fontsize=%(size)d" ) TIMECODE = ( @@ -39,6 +41,34 @@ TIMECODE_KEY = "{timecode}" SOURCE_TIMECODE_KEY = "{source_timecode}" +def convert_list_to_cmd(list_to_convert, fps, label=""): + path = None + #need to clean up temp file when done + with tempfile.NamedTemporaryFile(mode="w", delete=False) as f: + for i, value in enumerate(list_to_convert): + seconds = i / fps + + # Escape special character + value = str(value).replace(":", "\\:") + + filter = "drawtext" + if label: + filter += "@" + label + + line = ( + "{start} {filter} reinit text='{value}';" + "\n".format(start=seconds, filter=filter, value=value) + ) + + f.write(line) + f.flush() + path = f.name + path = path.replace("\\", "/") + path = path.replace(":", "\\:") + + return "sendcmd=f='{}'".format(path) + + def _get_ffprobe_data(source): """Reimplemented from otio burnins to be able use full path to ffprobe :param str source: source media file @@ -144,7 +174,7 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins): self.options_init.update(options_init) def add_text( - self, text, align, frame_start=None, frame_end=None, options=None + self, text, align, frame_start=None, frame_end=None, options=None, cmd="" ): """ Adding static text to a filter. @@ -165,7 +195,13 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins): if frame_end is not None: options["frame_end"] = frame_end - self._add_burnin(text, align, options, DRAWTEXT) + draw_text = DRAWTEXT + if cmd: + draw_text = "{}, {}".format(cmd, DRAWTEXT) + + options["label"] = align + + self._add_burnin(text, align, options, draw_text) def add_timecode( self, align, frame_start=None, frame_end=None, frame_start_tc=None, @@ -501,7 +537,7 @@ def burnins_from_data( if not value: continue - if isinstance(value, (dict, list, tuple)): + if isinstance(value, (dict, tuple)): raise TypeError(( "Expected string or number type." " Got: {} - \"{}\"" @@ -573,8 +609,43 @@ def burnins_from_data( burnin.add_timecode(*args) continue - text = value.format(**data) - burnin.add_text(text, align, frame_start, frame_end) + cmd = "" + text = None + keys = [i[1] for i in Formatter().parse(value) if i[1] is not None] + list_to_convert = [] + + # Warn about nested dictionary support for lists. Ei. we dont support + # it. + if "[" in "".join(keys): + print( + "We dont support converting nested dictionaries to lists," + " so skipping {}".format(value) + ) + else: + for key in keys: + data_value = data[key] + + # Multiple lists are not supported. + if isinstance(data_value, list) and list_to_convert: + raise ValueError( + "Found multiple lists to convert, which is not " + "supported: {}".format(value) + ) + + if isinstance(data_value, list): + print("Found list to convert: {}".format(data_value)) + for v in data_value: + data[key] = v + list_to_convert.append(value.format(**data)) + + if list_to_convert: + text = list_to_convert[0] + cmd = convert_list_to_cmd(list_to_convert, 25.0, label=align)# need to fetch fps properly + print("cmd: " + cmd) + else: + text = value.format(**data) + print(text) + burnin.add_text(text, align, frame_start, frame_end, cmd=cmd) ffmpeg_args = [] if codec_data: @@ -613,6 +684,8 @@ if __name__ == "__main__": with open(in_data_json_path, "r") as file_stream: in_data = json.load(file_stream) + print(json.dumps(in_data, indent=4, sort_keys=True)) + burnins_from_data( in_data["input"], in_data["output"], From 9eadc11941f4cffc6b1061f56f9751efd848c7de Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 22 Mar 2023 14:58:14 +0000 Subject: [PATCH 03/17] Update openpype/scripts/otio_burnin.py Co-authored-by: Roy Nieterau --- openpype/scripts/otio_burnin.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index bb7a208103..e7c165ba0e 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -684,8 +684,6 @@ if __name__ == "__main__": with open(in_data_json_path, "r") as file_stream: in_data = json.load(file_stream) - print(json.dumps(in_data, indent=4, sort_keys=True)) - burnins_from_data( in_data["input"], in_data["output"], From 22dac59ccf3d6269ec582c15de387fb23bc0e8e9 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 14:58:46 +0000 Subject: [PATCH 04/17] Store burnin data as dictionary directly. --- openpype/hosts/maya/plugins/publish/collect_review.py | 6 ++---- openpype/plugins/publish/extract_burnin.py | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/collect_review.py b/openpype/hosts/maya/plugins/publish/collect_review.py index 3d3ee09eed..0857e8224d 100644 --- a/openpype/hosts/maya/plugins/publish/collect_review.py +++ b/openpype/hosts/maya/plugins/publish/collect_review.py @@ -161,9 +161,7 @@ class CollectReview(pyblish.api.InstancePlugin): ] key = "focalLength" - instance.data[key] = focal_length - try: - instance.data["burninDataMembers"].append(key) + instance.data["burninDataMembers"][key] = focal_length except KeyError: - instance.data["burninDataMembers"] = [key] + instance.data["burninDataMembers"] = {key: focal_length} diff --git a/openpype/plugins/publish/extract_burnin.py b/openpype/plugins/publish/extract_burnin.py index de876c8486..8d29f814b5 100644 --- a/openpype/plugins/publish/extract_burnin.py +++ b/openpype/plugins/publish/extract_burnin.py @@ -255,8 +255,7 @@ class ExtractBurnin(publish.Extractor): burnin_data["custom"] = custom_data # Add data members. - for key in instance.data.get("burninDataMembers", []): - burnin_data[key] = instance.data[key] + burnin_data.update(instance.data.get("burninDataMembers", {})) # Add source camera name to burnin data camera_name = repre.get("camera_name") From f0bdc76183098782b1b42b37db8bb9386f3f864a Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 14:59:40 +0000 Subject: [PATCH 05/17] Clean up prints --- openpype/scripts/otio_burnin.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index e7c165ba0e..fa3f1e3389 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -641,10 +641,9 @@ def burnins_from_data( if list_to_convert: text = list_to_convert[0] cmd = convert_list_to_cmd(list_to_convert, 25.0, label=align)# need to fetch fps properly - print("cmd: " + cmd) else: text = value.format(**data) - print(text) + burnin.add_text(text, align, frame_start, frame_end, cmd=cmd) ffmpeg_args = [] From 266992f93ba45706e126358dfc47d9a18aaf015f Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 22 Mar 2023 15:00:05 +0000 Subject: [PATCH 06/17] Update openpype/scripts/otio_burnin.py Co-authored-by: Roy Nieterau --- openpype/scripts/otio_burnin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index e7c165ba0e..5e32e8d267 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -537,7 +537,7 @@ def burnins_from_data( if not value: continue - if isinstance(value, (dict, tuple)): + if isinstance(value, dict): raise TypeError(( "Expected string or number type." " Got: {} - \"{}\"" From 4f334a1f8061dfb8d38b176f2b8468e33df26c23 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 15:02:31 +0000 Subject: [PATCH 07/17] Update type error message --- openpype/scripts/otio_burnin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index 58727bc6b8..142ab748af 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -539,7 +539,7 @@ def burnins_from_data( if isinstance(value, dict): raise TypeError(( - "Expected string or number type." + "Expected string, number or list type." " Got: {} - \"{}\"" " (Make sure you have new burnin presets)." ).format(str(type(value)), str(value))) From 4f0aafe560be44bd42baff8946ff5d336bf31714 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 15:08:32 +0000 Subject: [PATCH 08/17] Get FPS properly --- openpype/scripts/otio_burnin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index 142ab748af..ee29d240b2 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -640,7 +640,9 @@ def burnins_from_data( if list_to_convert: text = list_to_convert[0] - cmd = convert_list_to_cmd(list_to_convert, 25.0, label=align)# need to fetch fps properly + cmd = convert_list_to_cmd( + list_to_convert, data["fps"], label=align + ) else: text = value.format(**data) From a364a82b7dddf64bb8178c3e6b93ccc0565328d6 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 15:10:02 +0000 Subject: [PATCH 09/17] Hound --- openpype/scripts/otio_burnin.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index ee29d240b2..4bbb684deb 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -174,7 +174,13 @@ class ModifiedBurnins(ffmpeg_burnins.Burnins): self.options_init.update(options_init) def add_text( - self, text, align, frame_start=None, frame_end=None, options=None, cmd="" + self, + text, + align, + frame_start=None, + frame_end=None, + options=None, + cmd="" ): """ Adding static text to a filter. @@ -450,11 +456,13 @@ def burnins_from_data( True by default. Presets must be set separately. Should be dict with 2 keys: - - "options" - sets look of burnins - colors, opacity,...(more info: ModifiedBurnins doc) + - "options" - sets look of burnins - colors, opacity,... + (more info: ModifiedBurnins doc) - *OPTIONAL* default values are used when not included - "burnins" - contains dictionary with burnins settings - *OPTIONAL* burnins won't be added (easier is not to use this) - - each key of "burnins" represents Alignment, there are 6 possibilities: + - each key of "burnins" represents Alignment, + there are 6 possibilities: TOP_LEFT TOP_CENTERED TOP_RIGHT BOTTOM_LEFT BOTTOM_CENTERED BOTTOM_RIGHT - value must be string with text you want to burn-in From 84817a77a33d4e0236ca7cdc9e7300665f77571c Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 15:42:45 +0000 Subject: [PATCH 10/17] Code cosmetics --- .../hosts/maya/plugins/publish/collect_review.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/maya/plugins/publish/collect_review.py b/openpype/hosts/maya/plugins/publish/collect_review.py index 0857e8224d..ce11e8a71f 100644 --- a/openpype/hosts/maya/plugins/publish/collect_review.py +++ b/openpype/hosts/maya/plugins/publish/collect_review.py @@ -5,6 +5,7 @@ import pyblish.api from openpype.client import get_subset_by_name from openpype.pipeline import legacy_io +from openpype.hosts.maya.api.lib import get_attribute_input class CollectReview(pyblish.api.InstancePlugin): @@ -146,19 +147,16 @@ class CollectReview(pyblish.api.InstancePlugin): ) # Collect focal length. - #Refactor to lib or use available lib method. - plug = "{0}.focalLength".format(camera) + attr = camera + ".focalLength" focal_length = None - if not cmds.listConnections(plug, destination=False, source=True): - # Static. - focal_length = cmds.getAttr(plug) - else: - # Dynamic. + if get_attribute_input(attr): start = instance.data["frameStart"] end = instance.data["frameEnd"] + 1 focal_length = [ - cmds.getAttr(plug, time=t) for t in range(int(start), int(end)) + cmds.getAttr(attr, time=t) for t in range(int(start), int(end)) ] + else: + focal_length = cmds.getAttr(attr) key = "focalLength" try: From 7ff781f3bddff9b5923789cb3406e67162c43c1a Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 16:32:41 +0000 Subject: [PATCH 11/17] Clean up temporary files and support float truncating --- openpype/scripts/otio_burnin.py | 89 +++++++++++++++++---------------- 1 file changed, 47 insertions(+), 42 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index 4bbb684deb..afae4f9e08 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -41,9 +41,8 @@ TIMECODE_KEY = "{timecode}" SOURCE_TIMECODE_KEY = "{source_timecode}" -def convert_list_to_cmd(list_to_convert, fps, label=""): +def convert_list_to_commands(list_to_convert, fps, label=""): path = None - #need to clean up temp file when done with tempfile.NamedTemporaryFile(mode="w", delete=False) as f: for i, value in enumerate(list_to_convert): seconds = i / fps @@ -63,10 +62,8 @@ def convert_list_to_cmd(list_to_convert, fps, label=""): f.write(line) f.flush() path = f.name - path = path.replace("\\", "/") - path = path.replace(":", "\\:") - return "sendcmd=f='{}'".format(path) + return path def _get_ffprobe_data(source): @@ -541,6 +538,7 @@ def burnins_from_data( if source_timecode is not None: data[SOURCE_TIMECODE_KEY[1:-1]] = SOURCE_TIMECODE_KEY + clean_up_paths = [] for align_text, value in burnin_values.items(): if not value: continue @@ -583,8 +581,48 @@ def burnins_from_data( print("Source does not have set timecode value.") value = value.replace(SOURCE_TIMECODE_KEY, MISSING_KEY_VALUE) - key_pattern = re.compile(r"(\{.*?[^{0]*\})") + # Convert lists. + cmd = "" + text = None + keys = [i[1] for i in Formatter().parse(value) if i[1] is not None] + list_to_convert = [] + # Warn about nested dictionary support for lists. Ei. we dont support + # it. + if "[" in "".join(keys): + print( + "We dont support converting nested dictionaries to lists," + " so skipping {}".format(value) + ) + else: + for key in keys: + data_value = data[key] + + # Multiple lists are not supported. + if isinstance(data_value, list) and list_to_convert: + raise ValueError( + "Found multiple lists to convert, which is not " + "supported: {}".format(value) + ) + + if isinstance(data_value, list): + print("Found list to convert: {}".format(data_value)) + for v in data_value: + data[key] = v + list_to_convert.append(value.format(**data)) + + if list_to_convert: + value = list_to_convert[0] + path = convert_list_to_commands( + list_to_convert, data["fps"], label=align + ) + cmd = "sendcmd=f='{}'".format(path) + cmd = cmd.replace("\\", "/") + cmd = cmd.replace(":", "\\:") + clean_up_paths.append(path) + + # Failsafe for missing keys. + key_pattern = re.compile(r"(\{.*?[^{0]*\})") missing_keys = [] for group in key_pattern.findall(value): try: @@ -617,42 +655,7 @@ def burnins_from_data( burnin.add_timecode(*args) continue - cmd = "" - text = None - keys = [i[1] for i in Formatter().parse(value) if i[1] is not None] - list_to_convert = [] - - # Warn about nested dictionary support for lists. Ei. we dont support - # it. - if "[" in "".join(keys): - print( - "We dont support converting nested dictionaries to lists," - " so skipping {}".format(value) - ) - else: - for key in keys: - data_value = data[key] - - # Multiple lists are not supported. - if isinstance(data_value, list) and list_to_convert: - raise ValueError( - "Found multiple lists to convert, which is not " - "supported: {}".format(value) - ) - - if isinstance(data_value, list): - print("Found list to convert: {}".format(data_value)) - for v in data_value: - data[key] = v - list_to_convert.append(value.format(**data)) - - if list_to_convert: - text = list_to_convert[0] - cmd = convert_list_to_cmd( - list_to_convert, data["fps"], label=align - ) - else: - text = value.format(**data) + text = value.format(**data) burnin.add_text(text, align, frame_start, frame_end, cmd=cmd) @@ -685,6 +688,8 @@ def burnins_from_data( burnin.render( output_path, args=ffmpeg_args_str, overwrite=overwrite, **data ) + for path in clean_up_paths: + os.remove(path) if __name__ == "__main__": From 833e48ae0f5f31e57b920950a0f5cea38a967263 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Wed, 22 Mar 2023 16:43:56 +0000 Subject: [PATCH 12/17] Docs --- website/docs/pype2/admin_presets_plugins.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/docs/pype2/admin_presets_plugins.md b/website/docs/pype2/admin_presets_plugins.md index fcdc09439b..2a30e7e8e9 100644 --- a/website/docs/pype2/admin_presets_plugins.md +++ b/website/docs/pype2/admin_presets_plugins.md @@ -293,6 +293,7 @@ If source representation has suffix **"h264"** and burnin suffix is **"client"** - It is allowed to use [Anatomy templates](admin_config#anatomy) themselves in burnins if they can be filled with available data. - Additional keys in burnins: + | Burnin key | Description | | --- | --- | | frame_start | First frame number. | @@ -303,6 +304,7 @@ If source representation has suffix **"h264"** and burnin suffix is **"client"** | resolution_height | Resolution height. | | fps | Fps of an output. | | timecode | Timecode by frame start and fps. | + | focalLength | **Only available in Maya**

Camera focal length per frame. Use syntax `{focalLength:.2f}` for decimal truncating. Eg. `35.234985` with `{focalLength:.2f}` would produce `35.23`, whereas `{focalLength:.0f}` would produce `35`. | :::warning `timecode` is specific key that can be **only at the end of content**. (`"BOTTOM_RIGHT": "TC: {timecode}"`) From 52511c1e3f8924c89a100cdbe2f2d2c34923ef4f Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Mon, 27 Mar 2023 10:07:54 +0100 Subject: [PATCH 13/17] Update openpype/scripts/otio_burnin.py Co-authored-by: Roy Nieterau --- openpype/scripts/otio_burnin.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index afae4f9e08..1f151b5dc6 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -42,7 +42,22 @@ SOURCE_TIMECODE_KEY = "{source_timecode}" def convert_list_to_commands(list_to_convert, fps, label=""): - path = None + """Convert a list of values to a drawtext command file for ffmpeg `sendcmd` + + The list of values is expected to have a value per frame. If the video + file ends up being longer than the amount of samples per frame than the + last value will be held. + + Args: + list_to_convert (list): List of values per frame. + fps (float or int): The expected frame per seconds of the output file + label (str): Label for the + + Returns: + str: Filepath to the temporary drawtext command file. + + """ + with tempfile.NamedTemporaryFile(mode="w", delete=False) as f: for i, value in enumerate(list_to_convert): seconds = i / fps @@ -61,9 +76,7 @@ def convert_list_to_commands(list_to_convert, fps, label=""): f.write(line) f.flush() - path = f.name - - return path + return f.name def _get_ffprobe_data(source): From 28a4f09625f6dc7f9aad7c8cd6a26bfe25c4f370 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Mon, 27 Mar 2023 10:10:21 +0100 Subject: [PATCH 14/17] Finish method description --- openpype/scripts/otio_burnin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index 1f151b5dc6..ca0930537c 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -50,8 +50,9 @@ def convert_list_to_commands(list_to_convert, fps, label=""): Args: list_to_convert (list): List of values per frame. - fps (float or int): The expected frame per seconds of the output file - label (str): Label for the + fps (float or int): The expected frame per seconds of the output file. + label (str): Label for the drawtext, if specific drawtext filter is + required Returns: str: Filepath to the temporary drawtext command file. From eaca4f5551032ebea9a0790c331109ce88005290 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Mon, 27 Mar 2023 10:10:31 +0100 Subject: [PATCH 15/17] Change method name --- openpype/scripts/otio_burnin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/scripts/otio_burnin.py b/openpype/scripts/otio_burnin.py index ca0930537c..57a1dcfaff 100644 --- a/openpype/scripts/otio_burnin.py +++ b/openpype/scripts/otio_burnin.py @@ -41,7 +41,7 @@ TIMECODE_KEY = "{timecode}" SOURCE_TIMECODE_KEY = "{source_timecode}" -def convert_list_to_commands(list_to_convert, fps, label=""): +def convert_list_to_command(list_to_convert, fps, label=""): """Convert a list of values to a drawtext command file for ffmpeg `sendcmd` The list of values is expected to have a value per frame. If the video @@ -627,7 +627,7 @@ def burnins_from_data( if list_to_convert: value = list_to_convert[0] - path = convert_list_to_commands( + path = convert_list_to_command( list_to_convert, data["fps"], label=align ) cmd = "sendcmd=f='{}'".format(path) From 85196b68f4273518d62f83473df228487e3082d2 Mon Sep 17 00:00:00 2001 From: Toke Stuart Jepsen Date: Mon, 27 Mar 2023 17:06:13 +0100 Subject: [PATCH 16/17] Add maya specific burnin profile. --- .../defaults/project_settings/global.json | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/openpype/settings/defaults/project_settings/global.json b/openpype/settings/defaults/project_settings/global.json index aad17d54da..eb74078cf0 100644 --- a/openpype/settings/defaults/project_settings/global.json +++ b/openpype/settings/defaults/project_settings/global.json @@ -249,6 +249,29 @@ } } } + }, + { + "families": [], + "hosts": [ + "maya" + ], + "task_types": [], + "task_names": [], + "subsets": [], + "burnins": { + "maya_burnin": { + "TOP_LEFT": "{yy}-{mm}-{dd}", + "TOP_CENTERED": "{focalLength:.2f} mm", + "TOP_RIGHT": "{anatomy[version]}", + "BOTTOM_LEFT": "{username}", + "BOTTOM_CENTERED": "{asset}", + "BOTTOM_RIGHT": "{frame_start}-{current_frame}-{frame_end}", + "filter": { + "families": [], + "tags": [] + } + } + } } ] }, From 7264ce3aafd51c8fbd81dd1803a9242c161ad75b Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 29 Mar 2023 09:17:20 +0100 Subject: [PATCH 17/17] Update openpype/lib/execute.py --- openpype/lib/execute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/lib/execute.py b/openpype/lib/execute.py index 5ba62f177f..eba75389f1 100644 --- a/openpype/lib/execute.py +++ b/openpype/lib/execute.py @@ -199,7 +199,7 @@ def run_openpype_process(*args, **kwargs): # - fill more if you find more env = clean_envs_for_openpype_process(os.environ) - # Add OpenPype version if we are running from build. + # Only keep OpenPype version if we are running from build. if not is_running_from_build(): env.pop("OPENPYPE_VERSION", None)