Merge branch 'feature/PYPE-738-option-to-cut-handles-in-extrac' into develop

This commit is contained in:
Milan Kolar 2020-03-13 21:29:26 +01:00
commit 8e391b449b
4 changed files with 84 additions and 44 deletions

View file

@ -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,7 +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["handleEnd"] = int(data.get("handleEnd", 0))

View file

@ -4,7 +4,6 @@ import copy
import pype.api
import pyblish
from pypeapp import config
class ExtractBurnin(pype.api.Extractor):
@ -26,10 +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",
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"])
@ -59,6 +64,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 +98,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))

View file

@ -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`
"""
@ -31,12 +32,22 @@ 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")
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",
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)
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 +84,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 +156,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 +167,23 @@ 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_no_handles = frame_start + handle_start
frame_end_no_handles = frame_end - handle_end
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))
frame_start_no_handles = frame_start + handle_start
frame_end_no_handles = frame_end - handle_end
input_args.append("-i {}".format(full_input_path))
@ -191,7 +217,6 @@ class ExtractReview(pyblish.api.InstancePlugin):
]
)
output_args = []
codec_args = profile.get('codec', [])
output_args.extend(codec_args)
# preset's output data
@ -238,6 +263,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)
@ -351,14 +383,19 @@ 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({
"stagingDir": stg_dir,
"files": os.listdir(stg_dir)
})
if no_handles:
repre_new.update({
"outputName": name + "_noHandles",
"startFrameReview": frame_start_no_handles,
"endFrameReview": frame_end_no_handles
})
if repre_new.get('preview'):
repre_new.pop("preview")
if repre_new.get('thumbnail'):

View file

@ -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))