Skip to content

Commit

Permalink
Merge pull request #17 from planetx-vfx/feature/FP-85/add-timecode-to…
Browse files Browse the repository at this point in the history
…-preview

FP-85 Add the proper timecode to the preview
  • Loading branch information
MaximumFX authored Oct 2, 2024
2 parents fa31ed4 + bbd76da commit d34bd11
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 181 deletions.
5 changes: 5 additions & 0 deletions info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ configuration:
fields: context, *
description: "Template of the preview files."

input_sequence:
type: template
fields: context, version, SEQ, *
description: "Template to deliver the sequences from."

delivery_folder:
type: template
fields: prj, delivery_date, delivery_version
Expand Down
2 changes: 1 addition & 1 deletion python/app/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def load_csv_templates(self):
self.view.csv_templates.clear()

if not self.csv_template_folder.is_dir():
self.csv_template_folder.mkdir(exist_ok=True)
self.csv_template_folder.mkdir(parents=True, exist_ok=True)
return

for dir_path, dir_names, file_names in os.walk(
Expand Down
68 changes: 45 additions & 23 deletions python/app/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,7 @@ def deliver_version(
return

try:
input_sequence_template = self.app.get_template("input_sequence")
delivery_folder_template = self.app.get_template("delivery_folder")
preview_movie_template = self.app.get_template("preview_movie")
delivery_sequence_template = self.app.get_template(
Expand All @@ -641,6 +642,24 @@ def deliver_version(
if fields is not None:
template_fields = {**fields, **template_fields}

# Get timecode ref path
timecode_template_fields = {**template_fields, "version": 0}
timecode_ref_path = None
input_sequence = Path(
input_sequence_template.apply_fields(timecode_template_fields)
)
self.logger.info("input_sequence")
self.logger.info(input_sequence)
input_frame = input_sequence.with_name(
input_sequence.name % version.first_frame
)
if input_frame.is_file():
timecode_ref_path = input_sequence
else:
input_sequence = Path(version.sequence_path)
if Path(version.sequence_path % version.first_frame).is_file():
timecode_ref_path = input_sequence

# Get the delivery folder
delivery_folder = Path(
delivery_folder_template.apply_fields(template_fields)
Expand Down Expand Up @@ -685,31 +704,34 @@ def deliver_version(
update_progress_bars,
0.5 if deliverables.deliver_sequence else 1.0,
)
args = [
"-t",
self.slate_path,
str(version.first_frame),
str(version.last_frame),
str(version.fps),
preview_movie_file.as_posix(),
output_preview_path.as_posix(),
self.settings.sg_server_path,
self.settings.sg_script_name,
self.settings.sg_script_key,
self.logo_path,
"--version-id",
version.id_str,
"-idt",
self.settings.preview_colorspace_idt,
"-odt",
self.settings.preview_colorspace_odt,
"--font-path",
self.font_path,
"--font-bold-path",
self.font_bold_path,
]
if timecode_ref_path is not None:
args.extend(["--timecode-ref", str(timecode_ref_path)])
process.run(
self.nuke_path,
[
"-t",
self.slate_path,
str(version.first_frame),
str(version.last_frame),
str(version.fps),
preview_movie_file.as_posix(),
output_preview_path.as_posix(),
self.settings.sg_server_path,
self.settings.sg_script_name,
self.settings.sg_script_key,
self.logo_path,
"--version-id",
version.id_str,
"-idt",
self.settings.preview_colorspace_idt,
"-odt",
self.settings.preview_colorspace_odt,
"--font-path",
self.font_path,
"--font-bold-path",
self.font_bold_path,
],
args,
)

self.logger.info(
Expand Down
40 changes: 26 additions & 14 deletions python/app/slate.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def __init__(
company="ShotGrid",
colorspace_idt="ACES - ACEScg",
colorspace_odt="Output - sRGB",
timecode_ref: str = None,
publish_id: int = None,
version_id: int = None,
font_path: str = None,
Expand All @@ -91,6 +92,7 @@ def __init__(
self.company = company
self.colorspace_idt = colorspace_idt
self.colorspace_odt = colorspace_odt
self.timecode_ref = timecode_ref.replace(os.sep, "/")
self.publish_id = publish_id
self.version_id = version_id
self.font_path = font_path
Expand Down Expand Up @@ -401,17 +403,35 @@ def __setup_slate(
# Create slate node
nuke.nodePaste(slate_node_path)

for node in nuke.selectedNodes():
node["selected"].setValue(False)

input = nuke.toNode("INPUT")
add_timecode = nuke.toNode("AddTimeCode")
slate = nuke.toNode("NETFLIX_TEMPLATE_SLATE")

# Set read node as input for slate node
input.setInput(0, read_node)

print("TIMECODE", self.timecode_ref)
if self.timecode_ref is not None:
timecode = nuke.nodes.Read(file=self.timecode_ref)
timecode["name"].setValue("Timecode")
timecode["first"].setValue(self.first_frame)
timecode["last"].setValue(self.last_frame)
timecode["origfirst"].setValue(self.first_frame)
timecode["origlast"].setValue(self.last_frame)

if (
add_timecode.metadata("input/timecode", self.first_frame)
== "00:00:00:00"
):
time = slate.node("AddTimeCode1")
time.knob("startcode").setValue("0")
time.knob("frame").setValue(self.first_frame - 1)

add_timecode.knob("frame").setValue(self.first_frame)

if self.logo_path.endswith(".nk"):
logo = nuke.nodePaste(self.logo_path)

for node in nuke.selectedNodes():
node["selected"].setValue(False)

slate.setInput(1, logo)
else:
logo = nuke.nodes.Read(file=self.logo_path)
Expand Down Expand Up @@ -456,11 +476,6 @@ def __setup_slate(
int((self.first_frame + self.last_frame) / 2)
)

# Manual AddTimeCode fix
time = slate.node("AddTimeCode1")
time.knob("startcode").setValue("0")
time.knob("frame").setValue(self.first_frame)

# TODO Actual episode implementation
if "_" in sg_shot["sg_sequence"]["name"]:
episode, scene = sg_shot["sg_sequence"]["name"].split("_")
Expand Down Expand Up @@ -489,9 +504,6 @@ def __setup_slate(
slate.knob("font").setValue(self.font_path)
slate.knob("font_bold").setValue(self.font_bold_path)

# Set read node as input for slate node
slate.setInput(0, read_node)

# Return created node
return slate

Expand Down
3 changes: 3 additions & 0 deletions python/app/slate_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
type=str,
metavar="colorspace",
)
parser.add_argument(
"--timecode-ref", type=str, help="Path to sequence with correct timecode"
)

shotgrid = parser.add_argument_group("ShotGrid")
shotgrid.add_argument(
Expand Down
Loading

0 comments on commit d34bd11

Please sign in to comment.