-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import pyblish.api | ||
|
||
|
||
class CollectClipResolution(pyblish.api.InstancePlugin): | ||
"""Collect clip geometry resolution""" | ||
|
||
order = pyblish.api.CollectorOrder + 0.101 | ||
label = "Collect Clip Resoluton" | ||
hosts = ["nukestudio"] | ||
|
||
def process(self, instance): | ||
sequence = instance.context.data['activeSequence'] | ||
resolution_width = int(sequence.format().width()) | ||
resolution_height = int(sequence.format().height()) | ||
pixel_aspect = sequence.format().pixelAspect() | ||
|
||
instance.data.update({ | ||
"resolutionWidth": resolution_width, | ||
"resolutionHeight": resolution_height, | ||
"pixelAspect": pixel_aspect | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
class ExtractReviewCutUpVideo(pype.api.Extractor): | ||
"""Cut up clips from long video file""" | ||
|
||
order = api.ExtractorOrder | ||
# order = api.CollectorOrder + 0.1023 | ||
# order = api.ExtractorOrder | ||
order = api.CollectorOrder + 0.1023 | ||
label = "Extract Review CutUp Video" | ||
hosts = ["nukestudio"] | ||
families = ["review"] | ||
|
@@ -22,7 +22,16 @@ def process(self, instance): | |
# get representation and loop them | ||
representations = inst_data["representations"] | ||
|
||
# resolution data | ||
resolution_width = inst_data["resolutionWidth"] | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
mkolar
Member
|
||
resolution_height = inst_data["resolutionHeight"] | ||
pixel_aspect = inst_data["pixelAspect"] | ||
|
||
# frame range data | ||
media_duration = inst_data["mediaDuration"] | ||
|
||
ffmpeg_path = pype.lib.get_ffmpeg_tool_path("ffmpeg") | ||
ffprobe_path = pype.lib.get_ffmpeg_tool_path("ffprobe") | ||
|
||
# filter out mov and img sequences | ||
representations_new = representations[:] | ||
|
@@ -32,7 +41,9 @@ def process(self, instance): | |
|
||
tags = repre.get("tags", []) | ||
|
||
if "cut-up" not in tags: | ||
if not next( | ||
(t for t in tags | ||
if t in ["_cut-bigger", "_cut-smaller"]), None): | ||
This comment has been minimized.
Sorry, something went wrong.
iLLiCiTiT
Member
|
||
continue | ||
|
||
self.log.debug("__ repre: {}".format(repre)) | ||
|
@@ -49,21 +60,77 @@ def process(self, instance): | |
full_input_path = os.path.join( | ||
staging_dir, file) | ||
|
||
full_output_dir = os.path.join( | ||
staging_dir, "cuts") | ||
|
||
os.path.isdir(full_output_dir) or os.makedirs(full_output_dir) | ||
|
||
full_output_path = os.path.join( | ||
staging_dir, new_file_name) | ||
full_output_dir, new_file_name) | ||
|
||
self.log.debug("__ full_input_path: {}".format(full_input_path)) | ||
self.log.debug("__ full_output_path: {}".format(full_output_path)) | ||
|
||
input_args.append("-y") | ||
input_args.append("-i {}".format(full_input_path)) | ||
# check if audio stream is in input video file | ||
ffprob_cmd = ( | ||
"{ffprobe_path} -i {full_input_path} -show_streams " | ||
"-select_streams a -loglevel error" | ||
).format(**locals()) | ||
This comment has been minimized.
Sorry, something went wrong.
iLLiCiTiT
Member
|
||
self.log.debug("ffprob_cmd: {}".format(ffprob_cmd)) | ||
audio_check_output = pype.api.subprocess(ffprob_cmd) | ||
self.log.debug("audio_check_output: {}".format(audio_check_output)) | ||
|
||
# translate frame to sec | ||
start_sec = float(frame_start) / fps | ||
duration_sec = float(frame_end - frame_start + 1) / fps | ||
|
||
input_args.append("-y") | ||
This comment has been minimized.
Sorry, something went wrong.
iLLiCiTiT
Member
|
||
|
||
if start_sec < 0: | ||
audio_empty = "" | ||
audio_output = "" | ||
audio_layer = "" | ||
v_inp_idx = 0 | ||
black_duration = abs(start_sec) | ||
start_sec = 0 | ||
duration_sec = float(frame_end - ( | ||
frame_start + (black_duration * fps)) + 1) / fps | ||
|
||
if audio_check_output: | ||
# adding input for empty audio | ||
input_args.append("-f lavfi -i anullsrc") | ||
audio_empty = ( | ||
"[0]atrim=duration={black_duration}[ga0];" | ||
).format(**locals()) | ||
audio_output = ":a=1" | ||
audio_layer = "[ga0]" | ||
v_inp_idx = 1 | ||
|
||
# adding input for video black frame | ||
input_args.append(( | ||
"-f lavfi -i \"color=c=black:" | ||
"s={resolution_width}x{resolution_height}:r={fps}\"" | ||
).format(**locals())) | ||
|
||
# concutting black frame togather | ||
output_args.append(( | ||
"-filter_complex \"" | ||
"{audio_empty}" | ||
"[{v_inp_idx}]trim=duration={black_duration}[gv0];" | ||
"[gv0]{audio_layer}[1:v]" | ||
"concat=n=2:v=1{audio_output}\"" | ||
).format(**locals())) | ||
This comment has been minimized.
Sorry, something went wrong.
iLLiCiTiT
Member
|
||
|
||
input_args.append("-ss {:0.2f}".format(start_sec)) | ||
input_args.append("-t {:0.2f}".format(duration_sec)) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
input_args.append("-i {}".format(full_input_path)) | ||
|
||
output_args.append("-c copy") | ||
duration_sec = float(frame_end - frame_start + 1) / fps | ||
output_args.append("-t {:0.2f}".format(duration_sec)) | ||
# check if not missing frames at the end | ||
self.log.debug("media_duration: {}".format(media_duration)) | ||
self.log.debug("frame_end: {}".format(frame_end)) | ||
|
||
# make sure it is having no frame to frame comprassion | ||
output_args.append("-intra") | ||
This comment has been minimized.
Sorry, something went wrong.
iLLiCiTiT
Member
|
||
|
||
# output filename | ||
output_args.append(full_output_path) | ||
|
@@ -90,7 +157,7 @@ def process(self, instance): | |
"step": 1, | ||
"fps": fps, | ||
"name": "cut_up_preview", | ||
"tags": ["cut-up", "review", "delete"] + self.tags_addition, | ||
"tags": ["review", "delete"] + self.tags_addition, | ||
"ext": ext, | ||
"anatomy_template": "publish" | ||
} | ||
|
This is just my opinion but it would be safer to use input's width and height get from ffprobe, instead of resolution stored in
instance.data
.