Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #23 from pypeclub/feature/PYPE-654-nks-cut-referen…
Browse files Browse the repository at this point in the history
…ce-videos

nks cut reference videos
  • Loading branch information
mkolar authored May 20, 2020
2 parents dce2f14 + 0c5b7b7 commit 9fd3d56
Show file tree
Hide file tree
Showing 12 changed files with 541 additions and 84 deletions.
2 changes: 1 addition & 1 deletion pype/plugins/global/publish/extract_burnin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ExtractBurnin(pype.api.Extractor):
label = "Extract burnins"
order = pyblish.api.ExtractorOrder + 0.03
families = ["review", "burnin"]
hosts = ["nuke", "maya", "shell", "premiere"]
hosts = ["nuke", "maya", "shell", "nukestudio", "premiere"]
optional = True

def process(self, instance):
Expand Down
13 changes: 10 additions & 3 deletions pype/plugins/global/publish/extract_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ class ExtractReview(pyblish.api.InstancePlugin):
label = "Extract Review"
order = pyblish.api.ExtractorOrder + 0.02
families = ["review"]
hosts = ["nuke", "maya", "shell", "premiere"]
hosts = ["nuke", "maya", "shell", "nukestudio", "premiere"]

outputs = {}
ext_filter = []
to_width = 1920
to_height = 1080

def process(self, instance):

def process(self, instance):
output_profiles = self.outputs or {}

inst_data = instance.data
Expand Down Expand Up @@ -82,6 +82,12 @@ def process(self, instance):
repre_new = repre.copy()
ext = profile.get("ext", None)
p_tags = profile.get('tags', [])

# append repre tags into profile tags
for t in tags:
if t not in p_tags:
p_tags.append(t)

self.log.info("p_tags: `{}`".format(p_tags))

# adding control for presets to be sequence
Expand Down Expand Up @@ -175,7 +181,8 @@ def process(self, instance):
frame_start_handle = frame_start - handle_start
frame_end_handle = frame_end + handle_end
if isinstance(repre["files"], list):
if frame_start_handle != repre.get("detectedStart", frame_start_handle):
if frame_start_handle != repre.get(
"detectedStart", frame_start_handle):
frame_start_handle = repre.get("detectedStart")

# exclude handle if no handles defined
Expand Down
3 changes: 3 additions & 0 deletions pype/plugins/global/publish/integrate_new.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ def register(self, instance):
sequence_repre = isinstance(files, list)
repre_context = None
if sequence_repre:
self.log.debug(
"files: {}".format(files))
src_collections, remainder = clique.assemble(files)
self.log.debug(
"src_tail_collections: {}".format(str(src_collections)))
Expand Down Expand Up @@ -347,6 +349,7 @@ def register(self, instance):
anatomy.templates["render"].get("padding")
)
)

index_frame_start = int(repre.get("frameStart"))

# exception for slate workflow
Expand Down
90 changes: 90 additions & 0 deletions pype/plugins/nukestudio/_unused/collect_timecodes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import pyblish.api
import opentimelineio.opentime as otio_ot


class CollectClipTimecodes(pyblish.api.InstancePlugin):
"""Collect time with OpenTimelineIO:
source_h(In,Out)[timecode, sec]
timeline(In,Out)[timecode, sec]
"""

order = pyblish.api.CollectorOrder + 0.101
label = "Collect Timecodes"
hosts = ["nukestudio"]

def process(self, instance):

data = dict()
self.log.debug("__ instance.data: {}".format(instance.data))
# Timeline data.
handle_start = instance.data["handleStart"]
handle_end = instance.data["handleEnd"]

source_in_h = instance.data("sourceInH",
instance.data("sourceIn") - handle_start)
source_out_h = instance.data("sourceOutH",
instance.data("sourceOut") + handle_end)

timeline_in = instance.data["clipIn"]
timeline_out = instance.data["clipOut"]

# set frame start with tag or take it from timeline
frame_start = instance.data.get("startingFrame")

if not frame_start:
frame_start = timeline_in

source = instance.data.get("source")

otio_data = dict()
self.log.debug("__ source: `{}`".format(source))

rate_fps = instance.context.data["fps"]

otio_in_h_ratio = otio_ot.RationalTime(
value=(source.timecodeStart() + (
source_in_h + (source_out_h - source_in_h))),
rate=rate_fps)

otio_out_h_ratio = otio_ot.RationalTime(
value=(source.timecodeStart() + source_in_h),
rate=rate_fps)

otio_timeline_in_ratio = otio_ot.RationalTime(
value=int(
instance.data.get("timelineTimecodeStart", 0)) + timeline_in,
rate=rate_fps)

otio_timeline_out_ratio = otio_ot.RationalTime(
value=int(
instance.data.get("timelineTimecodeStart", 0)) + timeline_out,
rate=rate_fps)

otio_data.update({

"otioClipInHTimecode": otio_ot.to_timecode(otio_in_h_ratio),

"otioClipOutHTimecode": otio_ot.to_timecode(otio_out_h_ratio),

"otioClipInHSec": otio_ot.to_seconds(otio_in_h_ratio),

"otioClipOutHSec": otio_ot.to_seconds(otio_out_h_ratio),

"otioTimelineInTimecode": otio_ot.to_timecode(
otio_timeline_in_ratio),

"otioTimelineOutTimecode": otio_ot.to_timecode(
otio_timeline_out_ratio),

"otioTimelineInSec": otio_ot.to_seconds(otio_timeline_in_ratio),

"otioTimelineOutSec": otio_ot.to_seconds(otio_timeline_out_ratio)
})

data.update({
"otioData": otio_data,
"sourceTimecodeIn": otio_ot.to_timecode(otio_in_h_ratio),
"sourceTimecodeOut": otio_ot.to_timecode(otio_out_h_ratio)
})
instance.data.update(data)
self.log.debug("data: {}".format(instance.data))
21 changes: 21 additions & 0 deletions pype/plugins/nukestudio/publish/collect_clip_resolution.py
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
})
89 changes: 61 additions & 28 deletions pype/plugins/nukestudio/publish/collect_clips.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,42 @@ def process(self, context):
track = item.parent()
source = item.source().mediaSource()
source_path = source.firstpath()
clip_in = int(item.timelineIn())
clip_out = int(item.timelineOut())
file_head = source.filenameHead()
file_info = next((f for f in source.fileinfos()), None)
source_first_frame = file_info.startFrame()
source_first_frame = int(file_info.startFrame())
is_sequence = False

self.log.debug(
"__ assets_shared: {}".format(
context.data["assetsShared"]))

# Check for clips with the same range
# this is for testing if any vertically neighbouring
# clips has been already processed
clip_matching_with_range = next(
(k for k, v in context.data["assetsShared"].items()
if (v.get("_clipIn", 0) == clip_in)
and (v.get("_clipOut", 0) == clip_out)
), False)

# check if clip name is the same in matched
# vertically neighbouring clip
# if it is then it is correct and resent variable to False
# not to be rised wrong name exception
if asset in str(clip_matching_with_range):
clip_matching_with_range = False

# rise wrong name exception if found one
assert (not clip_matching_with_range), (
"matching clip: {asset}"
" timeline range ({clip_in}:{clip_out})"
" conflicting with {clip_matching_with_range}"
" >> rename any of clips to be the same as the other <<"
).format(
**locals())

if not source.singleFile():
self.log.info("Single file")
is_sequence = True
Expand Down Expand Up @@ -89,40 +120,42 @@ def process(self, context):
)

data.update({
"name": "{0}_{1}".format(track.name(), item.name()),
"item": item,
"source": source,
"timecodeStart": str(source.timecodeStart()),
"timelineTimecodeStart": str(sequence.timecodeStart()),
"sourcePath": source_path,
"sourceFileHead": file_head,
"isSequence": is_sequence,
"track": track.name(),
"trackIndex": track_index,
"sourceFirst": source_first_frame,
"effects": effects,
"sourceIn": int(item.sourceIn()),
"sourceOut": int(item.sourceOut()),
"mediaDuration": (int(item.sourceOut()) -
int(item.sourceIn())) + 1,
"clipIn": int(item.timelineIn()),
"clipOut": int(item.timelineOut()),
"clipDuration": (
int(item.timelineOut()) - int(
item.timelineIn())) + 1,
"asset": asset,
"family": "clip",
"families": [],
"handleStart": projectdata.get("handleStart", 0),
"handleEnd": projectdata.get("handleEnd", 0)})
"name": "{0}_{1}".format(track.name(), item.name()),
"item": item,
"source": source,
"timecodeStart": str(source.timecodeStart()),
"timelineTimecodeStart": str(sequence.timecodeStart()),
"sourcePath": source_path,
"sourceFileHead": file_head,
"isSequence": is_sequence,
"track": track.name(),
"trackIndex": track_index,
"sourceFirst": source_first_frame,
"effects": effects,
"sourceIn": int(item.sourceIn()),
"sourceOut": int(item.sourceOut()),
"mediaDuration": int(source.duration()),
"clipIn": clip_in,
"clipOut": clip_out,
"clipDuration": (
int(item.timelineOut()) - int(
item.timelineIn())) + 1,
"asset": asset,
"family": "clip",
"families": [],
"handleStart": projectdata.get("handleStart", 0),
"handleEnd": projectdata.get("handleEnd", 0)})

instance = context.create_instance(**data)

self.log.info("Created instance: {}".format(instance))
self.log.info("Created instance.data: {}".format(instance.data))
self.log.debug(">> effects: {}".format(instance.data["effects"]))

context.data["assetsShared"][asset] = dict()
context.data["assetsShared"][asset] = {
"_clipIn": clip_in,
"_clipOut": clip_out
}

# from now we are collecting only subtrackitems on
# track with no video items
Expand Down
17 changes: 9 additions & 8 deletions pype/plugins/nukestudio/publish/collect_frame_ranges.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ def process(self, instance):

frame_end = frame_start + (timeline_out - timeline_in)

data.update(
{
"sourceInH": source_in_h,
"sourceOutH": source_out_h,
"frameStart": frame_start,
"frameEnd": frame_end,
"clipInH": timeline_in_h,
"clipOutH": timeline_out_h
data.update({
"sourceInH": source_in_h,
"sourceOutH": source_out_h,
"frameStart": frame_start,
"frameEnd": frame_end,
"clipInH": timeline_in_h,
"clipOutH": timeline_out_h,
"clipDurationH": instance.data.get(
"clipDuration") + handle_start + handle_end
}
)
self.log.debug("__ data: {}".format(data))
Expand Down
12 changes: 11 additions & 1 deletion pype/plugins/nukestudio/publish/collect_framerate.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pyblish import api


class CollectFramerate(api.ContextPlugin):
"""Collect framerate from selected sequence."""

Expand All @@ -9,4 +10,13 @@ class CollectFramerate(api.ContextPlugin):

def process(self, context):
sequence = context.data["activeSequence"]
context.data["fps"] = sequence.framerate().toFloat()
context.data["fps"] = self.get_rate(sequence)

def get_rate(self, sequence):
num, den = sequence.framerate().toRational()
rate = float(num) / float(den)

if rate.is_integer():
return rate

return round(rate, 3)
Loading

0 comments on commit 9fd3d56

Please sign in to comment.