From 5547cec38cf887066564aec9a7f7316096f47eac Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Tue, 23 Jul 2019 12:41:05 +0100 Subject: [PATCH 1/3] Audio on review. Audio needs to be collected in host plugin. Audio is a collection of dicts with "offset" and "filename" members. --- pype/plugins/global/publish/extract_review.py | 35 ++++++++++++++++- pype/plugins/maya/publish/collect_review.py | 38 ++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index 3a764b19c3..efd7f05ca9 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -53,7 +53,7 @@ class ExtractReview(pyblish.api.InstancePlugin): ext = "mov" self.log.warning( "`ext` attribute not in output profile. Setting to default ext: `mov`") - + self.log.debug("instance.families: {}".format(instance.data['families'])) self.log.debug("profile.families: {}".format(profile['families'])) @@ -114,6 +114,36 @@ class ExtractReview(pyblish.api.InstancePlugin): input_args.append("-i {}".format(full_input_path)) + for audio in instance.data.get("audio", []): + offset_frames = ( + instance.data.get("startFrameReview") - + audio["offset"] + ) + offset_seconds = offset_frames / fps + + if offset_seconds > 0: + input_args.append("-ss") + else: + input_args.append("-itsoffset") + + input_args.append(str(abs(offset_seconds))) + + input_args.extend( + ["-i", audio["filename"]] + ) + + # Need to merge audio if there are more + # than 1 input. + if len(instance.data["audio"]) > 1: + input_args.extend( + [ + "-filter_complex", + "amerge", + "-ac", + "2" + ] + ) + output_args = [] # preset's output data output_args.extend(profile.get('output', [])) @@ -125,6 +155,9 @@ class ExtractReview(pyblish.api.InstancePlugin): output_args.append( "-filter:v drawbox=0:0:iw:round((ih-(iw*(1/{0})))/2):t=fill:c=black,drawbox=0:ih-round((ih-(iw*(1/{0})))/2):iw:round((ih-(iw*(1/{0})))/2):t=fill:c=black".format(lb)) + # In case audio is longer than video. + output_args.append("-shortest") + # output filename output_args.append(full_output_path) mov_args = [ diff --git a/pype/plugins/maya/publish/collect_review.py b/pype/plugins/maya/publish/collect_review.py index 52aff1d459..43442400c9 100644 --- a/pype/plugins/maya/publish/collect_review.py +++ b/pype/plugins/maya/publish/collect_review.py @@ -1,4 +1,4 @@ -from maya import cmds +from maya import cmds, mel import pymel.core as pm import pyblish.api @@ -74,3 +74,39 @@ class CollectReview(pyblish.api.InstancePlugin): instance.data["families"] = ['ftrack'] cmds.setAttr(str(instance) + '.active', 1) + + # Collect audio + playback_slider = mel.eval('$tmpVar=$gPlayBackSlider') + audio_name = cmds.timeControl(playback_slider, q=True, s=True) + display_sounds = cmds.timeControl( + playback_slider, q=True, displaySound=True + ) + + audio_nodes = [] + + if audio_name: + audio_nodes.append(pm.PyNode(audio_name)) + + if not audio_name and display_sounds: + start_frame = int(pm.playbackOptions(q=True, min=True)) + end_frame = float(pm.playbackOptions(q=True, max=True)) + frame_range = range(int(start_frame), int(end_frame)) + + for node in pm.ls(type="audio"): + # Check if frame range and audio range intersections, + # for whether to include this audio node or not. + start_audio = node.offset.get() + end_audio = node.offset.get() + node.duration.get() + audio_range = range(int(start_audio), int(end_audio)) + + if bool(set(frame_range).intersection(audio_range)): + audio_nodes.append(node) + + instance.data["audio"] = [] + for node in audio_nodes: + instance.data["audio"].append( + { + "offset": node.offset.get(), + "filename": node.filename.get() + } + ) From ca2baae479c12ec3e17a7841c9cb1baf1903ff19 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Tue, 23 Jul 2019 12:41:43 +0100 Subject: [PATCH 2/3] Support tagging unwanted representations for deletion. --- pype/plugins/global/publish/extract_burnin.py | 11 ++++++++++- pype/plugins/maya/publish/extract_quicktime.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pype/plugins/global/publish/extract_burnin.py b/pype/plugins/global/publish/extract_burnin.py index 5f16cc91f2..85e851b389 100644 --- a/pype/plugins/global/publish/extract_burnin.py +++ b/pype/plugins/global/publish/extract_burnin.py @@ -82,10 +82,19 @@ class ExtractBurnin(pype.api.Extractor): if os.path.exists(full_burnin_path): repre_update = { "files": movieFileBurnin, - "name": repre["name"] + "name": repre["name"], + "tags": [x for x in repre["tags"] if x != "delete"] } instance.data["representations"][i].update(repre_update) # removing the source mov file os.remove(full_movie_path) self.log.debug("Removed: `{}`".format(full_movie_path)) + + # Remove any representations tagged for deletion. + for repre in instance.data["representations"]: + if "delete" in repre.get("tags", []): + self.log.debug("Removing representation: {}".format(repre)) + instance.data["representations"].remove(repre) + + self.log.debug(instance.data["representations"]) diff --git a/pype/plugins/maya/publish/extract_quicktime.py b/pype/plugins/maya/publish/extract_quicktime.py index 87608af641..26e115602c 100644 --- a/pype/plugins/maya/publish/extract_quicktime.py +++ b/pype/plugins/maya/publish/extract_quicktime.py @@ -118,7 +118,7 @@ class ExtractQuicktime(pype.api.Extractor): 'endFrame': end, 'frameRate': fps, 'preview': True, - 'tags': ['review'] + 'tags': ['review', 'delete'] } instance.data["representations"].append(representation) From 862bdf6ee2b96dbfc9cd4fba3f747356a60beb1e Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Tue, 23 Jul 2019 21:51:41 +0100 Subject: [PATCH 3/3] Bugfix for generating movie from jpegs tagged as "mov" extension. --- pype/plugins/global/publish/extract_review.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pype/plugins/global/publish/extract_review.py b/pype/plugins/global/publish/extract_review.py index efd7f05ca9..e067bf15b3 100644 --- a/pype/plugins/global/publish/extract_review.py +++ b/pype/plugins/global/publish/extract_review.py @@ -108,7 +108,7 @@ class ExtractReview(pyblish.api.InstancePlugin): # necessary input data # adds start arg only if image sequence - if "mov" not in repre_new['ext']: + if isinstance(repre["files"], list): input_args.append("-start_number {0} -framerate {1}".format( start_frame, fps))