From c40fa2fc2bb193698f74e63121b479e2dc599b09 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Wed, 27 Feb 2019 12:17:51 +0100 Subject: [PATCH] jpeg exctractor separated --- pype/plugins/global/publish/extract_jpeg.py | 51 +++++++++++++++++++ .../global/publish/extract_quicktime.py | 29 +++-------- 2 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 pype/plugins/global/publish/extract_jpeg.py diff --git a/pype/plugins/global/publish/extract_jpeg.py b/pype/plugins/global/publish/extract_jpeg.py new file mode 100644 index 0000000000..4bf0824bab --- /dev/null +++ b/pype/plugins/global/publish/extract_jpeg.py @@ -0,0 +1,51 @@ +import os +import pyblish.api +import subprocess +from pype.vendor import clique + + +class ExtractJpegEXR(pyblish.api.InstancePlugin): + """Resolve any dependency issies + + This plug-in resolves any paths which, if not updated might break + the published file. + + The order of families is important, when working with lookdev you want to + first publish the texture, update the texture paths in the nodes and then + publish the shading network. Same goes for file dependent assets. + """ + + label = "Extract Jpeg EXR" + order = pyblish.api.ExtractorOrder + families = ["imagesequence", "render", "write", "source"] + host = ["shell"] + + def process(self, instance): + start = instance.data.get("startFrame") + stagingdir = os.path.normpath(instance.data.get("stagingDir")) + + collected_frames = os.listdir(stagingdir) + collections, remainder = clique.assemble(collected_frames) + + input_file = ( + collections[0].format('{head}{padding}{tail}') % start + ) + full_input_path = os.path.join(stagingdir, input_file) + self.log.info("input {}".format(full_input_path)) + + filename = collections[0].format('{head}') + if not filename.endswith('.'): + filename += "." + jpegFile = filename + "jpg" + full_output_path = os.path.join(stagingdir, jpegFile) + + self.log.info("output {}".format(full_output_path)) + + subprocess_jpeg = "ffmpeg -y -gamma 2.2 -i {} {}".format( + full_input_path, full_output_path + ) + subprocess.Popen(subprocess_jpeg) + + if "files" not in instance.data: + instance.data["files"] = list() + instance.data["files"].append(jpegFile) diff --git a/pype/plugins/global/publish/extract_quicktime.py b/pype/plugins/global/publish/extract_quicktime.py index 3f1f02c7de..983c955484 100644 --- a/pype/plugins/global/publish/extract_quicktime.py +++ b/pype/plugins/global/publish/extract_quicktime.py @@ -27,41 +27,30 @@ class ExtractQuicktimeEXR(pyblish.api.InstancePlugin): collected_frames = os.listdir(stagingdir) collections, remainder = clique.assemble(collected_frames) - filename = collections[0].format('{head}') - input_path = os.path.join( + full_input_path = os.path.join( stagingdir, collections[0].format('{head}{padding}{tail}') ) - collections[0].format('{head}{padding}{tail}') - self.log.info("input {}".format(input_path)) - single_file_name = ( - collections[0].format('{head}{padding}{tail}') % start - ) - single_input_path = os.path.join(stagingdir, single_file_name) + self.log.info("input {}".format(full_input_path)) + + filename = collections[0].format('{head}') if not filename.endswith('.'): filename += "." movFile = filename + "mov" - jpegFile = filename + "jpg" - full_mov_path = os.path.join(stagingdir, movFile) - full_jpeg_path = os.path.join(stagingdir, jpegFile) + full_output_path = os.path.join(stagingdir, movFile) - self.log.info("output {}".format(full_mov_path)) - - subprocess_jpeg = "ffmpeg -y -gamma 2.2 -i {} {}".format( - single_input_path, full_jpeg_path - ) - subprocess.Popen(subprocess_jpeg) + self.log.info("output {}".format(full_output_path)) input_args = [ "-y -gamma 2.2", - "-i {}".format(input_path), + "-i {}".format(full_input_path), "-framerate {}".format(fps), "-start_number {}".format(start) ] output_args = [ "-c:v libx264", "-vf colormatrix=bt601:bt709", - full_mov_path + full_output_path ] mov_args = [ @@ -70,10 +59,8 @@ class ExtractQuicktimeEXR(pyblish.api.InstancePlugin): " ".join(output_args) ] subprocess_mov = " ".join(mov_args) - self.log.info("Mov args: {}".format(subprocess_mov)) subprocess.Popen(subprocess_mov) if "files" not in instance.data: instance.data["files"] = list() - # instance.data["files"].append(jpegFile) instance.data["files"].append(movFile)