From 6caa339d8254a65583e032cff9edfa90df82164b Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 13 Mar 2020 12:04:46 +0100 Subject: [PATCH 1/8] feat(global): adding no handles to extract burnin --- pype/plugins/global/publish/extract_burnin.py | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py index 008bebb271..3d5de28153 100644 --- a/pype/plugins/global/publish/extract_burnin.py +++ b/pype/plugins/global/publish/extract_burnin.py @@ -4,7 +4,6 @@ import copy import pype.api import pyblish -from pypeapp import config class ExtractBurnin(pype.api.Extractor): @@ -30,6 +29,8 @@ class ExtractBurnin(pype.api.Extractor): 'version', instance.context.data.get('version')) frame_start = int(instance.data.get("frameStart") or 0) frame_end = int(instance.data.get("frameEnd") or 1) + handle_start = instance.data.get("handleStart") + handle_end = instance.data.get("handleEnd") duration = frame_end - frame_start + 1 prep_data = copy.deepcopy(instance.data["anatomyData"]) @@ -59,6 +60,9 @@ class ExtractBurnin(pype.api.Extractor): is_sequence = "sequence" in repre.get("tags", []) + # no handles switch from profile tags + no_handles = "no-handles" in repre.get("tags", []) + stagingdir = repre["stagingDir"] filename = "{0}".format(repre["files"]) @@ -90,17 +94,32 @@ class ExtractBurnin(pype.api.Extractor): filled_anatomy = anatomy.format_all(_prep_data) _prep_data["anatomy"] = filled_anatomy.get_solved() + # copy frame range variables + frame_start_cp = frame_start + frame_end_cp = frame_end + duration_cp = duration + + if no_handles: + frame_start_cp = frame_start + handle_start + frame_end_cp = frame_end - handle_end + duration_cp = frame_end_cp - frame_start_cp + 1 + _prep_data.update({ + "frame_start": frame_start_cp, + "frame_end": frame_end_cp, + "duration": duration_cp, + }) + # dealing with slates - slate_frame_start = frame_start - slate_frame_end = frame_end - slate_duration = duration + slate_frame_start = frame_start_cp + slate_frame_end = frame_end_cp + slate_duration = duration_cp # exception for slate workflow if ("slate" in instance.data["families"]): if "slate-frame" in repre.get("tags", []): - slate_frame_start = frame_start - 1 - slate_frame_end = frame_end - slate_duration = duration + 1 + slate_frame_start = frame_start_cp - 1 + slate_frame_end = frame_end_cp + slate_duration = duration_cp + 1 self.log.debug("__1 slate_frame_start: {}".format(slate_frame_start)) From 0123c8c5776fc97887a7202082c4d27f84253004 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 13 Mar 2020 12:11:35 +0100 Subject: [PATCH 2/8] feat(global): extract review no handles tag --- pype/plugins/global/publish/extract_review.py | 45 +++++++++++++++---- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index f5dba108c5..c7f286c3e2 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -31,12 +31,17 @@ class ExtractReview(pyblish.api.InstancePlugin): output_profiles = self.outputs or {} inst_data = instance.data - fps = inst_data.get("fps") - start_frame = inst_data.get("frameStart") - resolution_width = inst_data.get("resolutionWidth", to_width) - resolution_height = inst_data.get("resolutionHeight", to_height) + fps = float(inst_data.get("fps")) + frame_start = inst_data.get("frameStart") + frame_end = inst_data.get("frameEnd") + handle_start = inst_data.get("handleStart") + handle_end = inst_data.get("handleEnd") pixel_aspect = inst_data.get("pixelAspect", 1) self.log.debug("Families In: `{}`".format(inst_data["families"])) + self.log.debug("__ frame_start: {}".format(frame_start)) + self.log.debug("__ frame_end: {}".format(frame_end)) + self.log.debug("__ handle_start: {}".format(handle_start)) + self.log.debug("__ handle_end: {}".format(handle_end)) # get representation and loop them representations = inst_data["representations"] @@ -73,6 +78,9 @@ class ExtractReview(pyblish.api.InstancePlugin): is_sequence = ("sequence" in p_tags) and (ext in ( "png", "jpg", "jpeg")) + # no handles switch from profile tags + no_handles = "no-handles" in p_tags + self.log.debug("Profile name: {}".format(name)) if not ext: @@ -142,6 +150,7 @@ class ExtractReview(pyblish.api.InstancePlugin): self.log.info("new_tags: `{}`".format(new_tags)) input_args = [] + output_args = [] # overrides output file input_args.append("-y") @@ -152,12 +161,20 @@ class ExtractReview(pyblish.api.InstancePlugin): # necessary input data # adds start arg only if image sequence if isinstance(repre["files"], list): + if frame_start != repre.get("detectedStart", frame_start): + frame_start = repre.get("detectedStart") + + # exclude handle if no handles defined + if no_handles: + frame_start += handle_start - if start_frame != repre.get("detectedStart", start_frame): - start_frame = repre.get("detectedStart") input_args.append( "-start_number {0} -framerate {1}".format( - start_frame, fps)) + frame_start, fps)) + else: + if no_handles: + start_sec = float(handle_start) / fps + input_args.append("-ss {:0.2f}".format(start_sec)) input_args.append("-i {}".format(full_input_path)) @@ -191,7 +208,6 @@ class ExtractReview(pyblish.api.InstancePlugin): ] ) - output_args = [] codec_args = profile.get('codec', []) output_args.extend(codec_args) # preset's output data @@ -238,6 +254,13 @@ class ExtractReview(pyblish.api.InstancePlugin): # In case audio is longer than video. output_args.append("-shortest") + if no_handles: + duration_sec = float( + (frame_end - ( + frame_start + handle_start + ) + 1) - handle_end) / fps + output_args.append("-t {:0.2f}".format(duration_sec)) + # output filename output_args.append(full_output_path) @@ -321,6 +344,7 @@ class ExtractReview(pyblish.api.InstancePlugin): self.log.debug( "_ output_args: `{}`".format(output_args)) + if is_sequence: stg_dir = os.path.dirname(full_output_path) @@ -358,7 +382,10 @@ class ExtractReview(pyblish.api.InstancePlugin): "stagingDir": stg_dir, "files": os.listdir(stg_dir) }) - + if no_handles: + repre_new.update({ + "outputName": name + "_noHandles" + }) if repre_new.get('preview'): repre_new.pop("preview") if repre_new.get('thumbnail'): From 76cb3b37e27b70840b999ceff69df02551078ef5 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 13 Mar 2020 16:42:25 +0100 Subject: [PATCH 3/8] fix(global): adding back resolution attribtes wrong commitment had erased them --- pype/plugins/global/publish/extract_review.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index c7f286c3e2..81d7e1668a 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -37,6 +37,8 @@ class ExtractReview(pyblish.api.InstancePlugin): handle_start = inst_data.get("handleStart") handle_end = inst_data.get("handleEnd") pixel_aspect = inst_data.get("pixelAspect", 1) + resolution_width = inst_data.get("resolutionWidth", self.to_width) + resolution_height = inst_data.get("resolutionHeight", self.to_height) self.log.debug("Families In: `{}`".format(inst_data["families"])) self.log.debug("__ frame_start: {}".format(frame_start)) self.log.debug("__ frame_end: {}".format(frame_end)) @@ -344,7 +346,6 @@ class ExtractReview(pyblish.api.InstancePlugin): self.log.debug( "_ output_args: `{}`".format(output_args)) - if is_sequence: stg_dir = os.path.dirname(full_output_path) From d484e5108c034edcc6d84de6038a23e10753f481 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Fri, 13 Mar 2020 18:02:52 +0100 Subject: [PATCH 4/8] fix(global): self.to_width and height is in another PR --- pype/plugins/global/publish/extract_review.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index 81d7e1668a..d03de6ad61 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -37,8 +37,8 @@ class ExtractReview(pyblish.api.InstancePlugin): handle_start = inst_data.get("handleStart") handle_end = inst_data.get("handleEnd") pixel_aspect = inst_data.get("pixelAspect", 1) - resolution_width = inst_data.get("resolutionWidth", self.to_width) - resolution_height = inst_data.get("resolutionHeight", self.to_height) + resolution_width = inst_data.get("resolutionWidth", to_width) + resolution_height = inst_data.get("resolutionHeight", to_height) self.log.debug("Families In: `{}`".format(inst_data["families"])) self.log.debug("__ frame_start: {}".format(frame_start)) self.log.debug("__ frame_end: {}".format(frame_end)) From ba55689b4339212e545a4c5da88800f5d362bd2a Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 13 Mar 2020 20:02:06 +0100 Subject: [PATCH 5/8] fall back to context handles if not present in instance --- pype/plugins/global/publish/collect_avalon_entities.py | 5 +++++ pype/plugins/global/publish/extract_burnin.py | 8 ++++++-- pype/plugins/global/publish/extract_review.py | 7 +++++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/pype/plugins/global/publish/collect_avalon_entities.py b/pype/plugins/global/publish/collect_avalon_entities.py index a429b3fc84..a4f14421f2 100644 --- a/pype/plugins/global/publish/collect_avalon_entities.py +++ b/pype/plugins/global/publish/collect_avalon_entities.py @@ -45,3 +45,8 @@ class CollectAvalonEntities(pyblish.api.ContextPlugin): context.data["projectEntity"] = project_entity context.data["assetEntity"] = asset_entity + + data = asset_entity['data'] + context.data['handles'] = int(data.get("handles", 0)) + context.data["handleStart"] = int(data.get( "handleStart", 0)) + context.data["handleEnd"] = int(data.get("handleEnd", 0)) diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py index 3d5de28153..faecbb47a7 100644 --- a/pype/plugins/global/publish/extract_burnin.py +++ b/pype/plugins/global/publish/extract_burnin.py @@ -25,12 +25,16 @@ class ExtractBurnin(pype.api.Extractor): if "representations" not in instance.data: raise RuntimeError("Burnin needs already created mov to work on.") + context_data = instance.context.data + version = instance.data.get( 'version', instance.context.data.get('version')) frame_start = int(instance.data.get("frameStart") or 0) frame_end = int(instance.data.get("frameEnd") or 1) - handle_start = instance.data.get("handleStart") - handle_end = instance.data.get("handleEnd") + handle_start = instance.data.get("handleStart", + context_data.get("handleStart")) + handle_end = instance.data.get("handleEnd", + context_data.get("handleEnd")) duration = frame_end - frame_start + 1 prep_data = copy.deepcopy(instance.data["anatomyData"]) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index d03de6ad61..7f88a89004 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -31,11 +31,14 @@ class ExtractReview(pyblish.api.InstancePlugin): output_profiles = self.outputs or {} inst_data = instance.data + context_data = instance.context.data fps = float(inst_data.get("fps")) frame_start = inst_data.get("frameStart") frame_end = inst_data.get("frameEnd") - handle_start = inst_data.get("handleStart") - handle_end = inst_data.get("handleEnd") + handle_start = inst_data.get("handleStart", + context_data.get("handleStart")) + handle_end = inst_data.get("handleEnd", + context_data.get("handleEnd")) pixel_aspect = inst_data.get("pixelAspect", 1) resolution_width = inst_data.get("resolutionWidth", to_width) resolution_height = inst_data.get("resolutionHeight", to_height) From 300ea97f1ecbce5c6f73761cae469b948b862af8 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 13 Mar 2020 20:32:29 +0100 Subject: [PATCH 6/8] move handles collection to global plugins --- .../global/publish/collect_avalon_entities.py | 6 ++--- .../nuke/publish/collect_asset_info.py | 25 ------------------- 2 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 pype/plugins/nuke/publish/collect_asset_info.py diff --git a/pype/plugins/global/publish/collect_avalon_entities.py b/pype/plugins/global/publish/collect_avalon_entities.py index a4f14421f2..20899361c5 100644 --- a/pype/plugins/global/publish/collect_avalon_entities.py +++ b/pype/plugins/global/publish/collect_avalon_entities.py @@ -30,7 +30,7 @@ class CollectAvalonEntities(pyblish.api.ContextPlugin): assert project_entity, ( "Project '{0}' was not found." ).format(project_name) - self.log.debug("Collected Project entity \"{}\"".format(project_entity)) + self.log.debug("Collected Project \"{}\"".format(project_entity)) asset_entity = io.find_one({ "type": "asset", @@ -41,12 +41,12 @@ class CollectAvalonEntities(pyblish.api.ContextPlugin): "No asset found by the name '{0}' in project '{1}'" ).format(asset_name, project_name) - self.log.debug("Collected Asset entity \"{}\"".format(asset_entity)) + self.log.debug("Collected Asset \"{}\"".format(asset_entity)) context.data["projectEntity"] = project_entity context.data["assetEntity"] = asset_entity data = asset_entity['data'] context.data['handles'] = int(data.get("handles", 0)) - context.data["handleStart"] = int(data.get( "handleStart", 0)) + context.data["handleStart"] = int(data.get("handleStart", 0)) context.data["handleEnd"] = int(data.get("handleEnd", 0)) diff --git a/pype/plugins/nuke/publish/collect_asset_info.py b/pype/plugins/nuke/publish/collect_asset_info.py deleted file mode 100644 index 8a8791ec36..0000000000 --- a/pype/plugins/nuke/publish/collect_asset_info.py +++ /dev/null @@ -1,25 +0,0 @@ -from avalon import api, io -import pyblish.api - - -class CollectAssetInfo(pyblish.api.ContextPlugin): - """Collect framerate.""" - - order = pyblish.api.CollectorOrder - label = "Collect Asset Info" - hosts = [ - "nuke", - "nukeassist" - ] - - def process(self, context): - asset_data = io.find_one({ - "type": "asset", - "name": api.Session["AVALON_ASSET"] - }) - self.log.info("asset_data: {}".format(asset_data)) - - context.data['handles'] = int(asset_data["data"].get("handles", 0)) - context.data["handleStart"] = int(asset_data["data"].get( - "handleStart", 0)) - context.data["handleEnd"] = int(asset_data["data"].get("handleEnd", 0)) From 7bd4182c30243ecb0f7e3803eb3157f62859f658 Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 13 Mar 2020 20:32:51 +0100 Subject: [PATCH 7/8] remove handles from ftrack frame range --- pype/plugins/global/publish/extract_review.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index 7f88a89004..fa29fd2fe0 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -12,7 +12,8 @@ class ExtractReview(pyblish.api.InstancePlugin): otherwise the representation is ignored. All new represetnations are created and encoded by ffmpeg following - presets found in `pype-config/presets/plugins/global/publish.json:ExtractReview:outputs`. To change the file extension + presets found in `pype-config/presets/plugins/global/ + publish.json:ExtractReview:outputs`. To change the file extension filter values use preset's attributes `ext_filter` """ @@ -171,7 +172,8 @@ class ExtractReview(pyblish.api.InstancePlugin): # exclude handle if no handles defined if no_handles: - frame_start += handle_start + frame_start_no_handles = frame_start + handle_start + frame_end_no_handles = frame_end - handle_end input_args.append( "-start_number {0} -framerate {1}".format( @@ -180,6 +182,8 @@ class ExtractReview(pyblish.api.InstancePlugin): if no_handles: start_sec = float(handle_start) / fps input_args.append("-ss {:0.2f}".format(start_sec)) + frame_start_no_handles += handle_start + frame_end_no_handles -= handle_end input_args.append("-i {}".format(full_input_path)) @@ -379,7 +383,7 @@ class ExtractReview(pyblish.api.InstancePlugin): "codec": codec_args, "_profile": profile, "resolutionHeight": resolution_height, - "resolutionWidth": resolution_width, + "resolutionWidth": resolution_width }) if is_sequence: repre_new.update({ @@ -388,7 +392,9 @@ class ExtractReview(pyblish.api.InstancePlugin): }) if no_handles: repre_new.update({ - "outputName": name + "_noHandles" + "outputName": name + "_noHandles", + "startFrameReview": frame_start_no_handles, + "endFrameReview": frame_end_no_handles }) if repre_new.get('preview'): repre_new.pop("preview") From 47f04e0fbaf3acf2f8cc1302674573f1aa3c6f6a Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Fri, 13 Mar 2020 20:41:28 +0100 Subject: [PATCH 8/8] fix frame range on review --- pype/plugins/global/publish/extract_review.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index fa29fd2fe0..23e582edd2 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -182,8 +182,8 @@ class ExtractReview(pyblish.api.InstancePlugin): if no_handles: start_sec = float(handle_start) / fps input_args.append("-ss {:0.2f}".format(start_sec)) - frame_start_no_handles += handle_start - frame_end_no_handles -= handle_end + frame_start_no_handles = frame_start + handle_start + frame_end_no_handles = frame_end - handle_end input_args.append("-i {}".format(full_input_path))