From b42e7bf8a3004c440151eb461ce3586d1257e919 Mon Sep 17 00:00:00 2001 From: antirotor Date: Sat, 6 Jul 2019 17:08:45 +0200 Subject: [PATCH 1/2] added global burnin extractor --- pype/plugins/global/publish/extract_burnin.py | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 pype/plugins/global/publish/extract_burnin.py diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py new file mode 100644 index 0000000000..e8eac1ef60 --- /dev/null +++ b/pype/plugins/global/publish/extract_burnin.py @@ -0,0 +1,57 @@ +import os +import subprocess +import pype.api +import json + + +class ExtractBurnin(pype.api.Extractor): + + label = "Quicktime with burnins" + families = ["burnin"] + optional = True + + def process(self, instance): + version = instance.context.data['version'] + stagingdir = self.staging_dir(instance) + filename = "{0}".format(instance.name) + + movieFile = filename + ".mov" + movieFileBurnin = filename + "Burn" + ".mov" + + full_movie_path = os.path.join(stagingdir, movieFile) + full_burnin_path = os.path.join(stagingdir, movieFileBurnin) + + burnin_data = { + "input": full_movie_path.replace("\\", "/"), + "output": full_burnin_path.replace("\\", "/"), + "burnin_data": { + "username": instance.context.data['user'], + "asset": os.environ['AVALON_ASSET'], + "task": os.environ['AVALON_TASK'], + "start_frame": int(instance.data['startFrame']), + "version": "v" + str(version) + } + } + + json_data = json.dumps(burnin_data) + scriptpath = os.path.join(os.environ['PYPE_MODULE_ROOT'], + "pype", + "scripts", + "otio_burnin.py") + + p = subprocess.Popen( + ['python', scriptpath, json_data] + ) + p.wait() + + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'mov', + 'ext': 'mov', + 'files': movieFileBurnin, + "stagingDir": stagingdir, + 'preview': True + } + instance.data["representations"].append(representation) From d2b6c7c1a93212c756f41e4fe5a5d2a182f84bef Mon Sep 17 00:00:00 2001 From: antirotor Date: Mon, 8 Jul 2019 21:19:24 +0200 Subject: [PATCH 2/2] fix(burnin): will now work on representations, expecting burnin = True or 'burnin' in tags --- pype/plugins/global/publish/extract_burnin.py | 88 ++++++++++--------- 1 file changed, 47 insertions(+), 41 deletions(-) diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py index e8eac1ef60..34ee33f602 100644 --- a/pype/plugins/global/publish/extract_burnin.py +++ b/pype/plugins/global/publish/extract_burnin.py @@ -5,53 +5,59 @@ import json class ExtractBurnin(pype.api.Extractor): + """ + Extractor to create video with pre-defined burnins from + existing extracted video representation. + + It will work only on represenations having `burnin = True` or + `tags` including `burnin` + """ label = "Quicktime with burnins" families = ["burnin"] optional = True def process(self, instance): - version = instance.context.data['version'] - stagingdir = self.staging_dir(instance) - filename = "{0}".format(instance.name) - - movieFile = filename + ".mov" - movieFileBurnin = filename + "Burn" + ".mov" - - full_movie_path = os.path.join(stagingdir, movieFile) - full_burnin_path = os.path.join(stagingdir, movieFileBurnin) - - burnin_data = { - "input": full_movie_path.replace("\\", "/"), - "output": full_burnin_path.replace("\\", "/"), - "burnin_data": { - "username": instance.context.data['user'], - "asset": os.environ['AVALON_ASSET'], - "task": os.environ['AVALON_TASK'], - "start_frame": int(instance.data['startFrame']), - "version": "v" + str(version) - } - } - - json_data = json.dumps(burnin_data) - scriptpath = os.path.join(os.environ['PYPE_MODULE_ROOT'], - "pype", - "scripts", - "otio_burnin.py") - - p = subprocess.Popen( - ['python', scriptpath, json_data] - ) - p.wait() - if "representations" not in instance.data: - instance.data["representations"] = [] + raise RuntimeError("Burnin needs already created mov to work on.") - representation = { - 'name': 'mov', - 'ext': 'mov', - 'files': movieFileBurnin, - "stagingDir": stagingdir, - 'preview': True + # TODO: expand burnin data list to include all usefull keys + burnin_data = { + "username": instance.context.data['user'], + "asset": os.environ['AVALON_ASSET'], + "task": os.environ['AVALON_TASK'], + "start_frame": int(instance.data['startFrame']), + "version": "v" + str(instance.context.data['version']) } - instance.data["representations"].append(representation) + + for repre in instance.data["representations"]: + if (not repre.get("burnin", False) or + "burnin" not in repre.get("tags", [])): + continue + + stagingdir = self.staging_dir(instance) + filename = "{0}".format(repre["files"]) + + movieFileBurnin = filename + "Burn" + ".mov" + + full_movie_path = os.path.join(stagingdir, repre["files"]) + full_burnin_path = os.path.join(stagingdir, movieFileBurnin) + + burnin_data = { + "input": full_movie_path.replace("\\", "/"), + "output": full_burnin_path.replace("\\", "/"), + "burnin_data": burnin_data + } + + json_data = json.dumps(burnin_data) + scriptpath = os.path.join(os.environ['PYPE_MODULE_ROOT'], + "pype", + "scripts", + "otio_burnin.py") + + p = subprocess.Popen( + ['python', scriptpath, json_data] + ) + p.wait() + + repre['files']: movieFileBurnin