Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ce41123c5 | |||
| 783e82eaf5 | |||
| c4abda2d63 |
@@ -230,6 +230,26 @@
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Slate identity fields (version name, shot name). Current templates expose
|
||||||
|
// these under a stable name, older ones only positionally, and the two do
|
||||||
|
// not always line up — so write both. Setting the same property twice is
|
||||||
|
// harmless; the panel uses the same name-with-index-fallback pattern.
|
||||||
|
function setSlateIdentity(layer, propName, index, value, label) {
|
||||||
|
var byName;
|
||||||
|
var byIndex;
|
||||||
|
|
||||||
|
if (value === null || value === undefined || value === "") {
|
||||||
|
return; // leave the template's own default
|
||||||
|
}
|
||||||
|
byName = setEssentialProperty(layer, propName, value);
|
||||||
|
byIndex = setEssentialPropertyByIndex(layer, index, value);
|
||||||
|
if (!byName && !byIndex) {
|
||||||
|
warn(label + ": neither Essential Property \"" + propName + "\" nor index " +
|
||||||
|
index + " could be set. Available: " +
|
||||||
|
listEssentialPropertyNames(layer).join(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Per-submission fields (VFX Scope / Submission Note). The property names
|
// Per-submission fields (VFX Scope / Submission Note). The property names
|
||||||
// come from config; if one does not exist, report the template's actual
|
// come from config; if one does not exist, report the template's actual
|
||||||
// property names so it can be corrected without another build.
|
// property names so it can be corrected without another build.
|
||||||
@@ -439,12 +459,15 @@
|
|||||||
|
|
||||||
var slateLayer = previewComp.layer("NETFLIX_SLATE");
|
var slateLayer = previewComp.layer("NETFLIX_SLATE");
|
||||||
if (slateLayer) {
|
if (slateLayer) {
|
||||||
// Index-addressed properties match the panel exactly (3 = version
|
// Identity fields match the panel's indices (3 = version name,
|
||||||
// name, 10 = shot code); the rest are addressed by name.
|
// 10 = shot name) and are also written by name; the rest are
|
||||||
setEssentialPropertyByIndex(slateLayer, 3, ctx.slate.versionName);
|
// addressed by name only.
|
||||||
|
// VersionName carries the full "{shotCode}_cmp_TT_{version}";
|
||||||
|
// ShotName is the bare shot code, with no version suffix.
|
||||||
|
setSlateIdentity(slateLayer, "VersionName", 3, ctx.slate.versionName, "Version Name");
|
||||||
|
setSlateIdentity(slateLayer, "ShotName", 10, ctx.slate.shotCode, "Shot Name");
|
||||||
setEssentialProperty(slateLayer, "Date", ctx.slate.date);
|
setEssentialProperty(slateLayer, "Date", ctx.slate.date);
|
||||||
setEssentialProperty(slateLayer, "Desc", ctx.slate.description);
|
setEssentialProperty(slateLayer, "Desc", ctx.slate.description);
|
||||||
setEssentialPropertyByIndex(slateLayer, 10, ctx.slate.shotCode);
|
|
||||||
setEssentialProperty(slateLayer, "Episode", ctx.slate.episode);
|
setEssentialProperty(slateLayer, "Episode", ctx.slate.episode);
|
||||||
setEssentialProperty(slateLayer, "Scene", ctx.slate.scene);
|
setEssentialProperty(slateLayer, "Scene", ctx.slate.scene);
|
||||||
setEssentialProperty(slateLayer, "Frames", result.frameCount);
|
setEssentialProperty(slateLayer, "Frames", result.frameCount);
|
||||||
|
|||||||
+104
-11
@@ -315,6 +315,27 @@ var SETTINGS_KEY = "cfg";
|
|||||||
return CONFIG.footageRoot + (showId ? "/" + showId : "");
|
return CONFIG.footageRoot + (showId ? "/" + showId : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mirrors the server's export layout so farm and local renders land together:
|
||||||
|
// {exportRoot}/{showId}/[{episode} for episodic]/{shotCode}/{version}
|
||||||
|
function getShotExportDir(shot) {
|
||||||
|
var path = getShowExportRoot();
|
||||||
|
var episode;
|
||||||
|
var match;
|
||||||
|
|
||||||
|
if (CURRENT_PROJECT && CURRENT_PROJECT.projectType === "EPISODIC") {
|
||||||
|
episode = trimText(shot.episode);
|
||||||
|
if (!episode) {
|
||||||
|
match = String(shot.shotCode).match(/^[A-Z]{3}_(\d{3})_/);
|
||||||
|
episode = match ? match[1] : "";
|
||||||
|
}
|
||||||
|
if (episode) {
|
||||||
|
path += "/" + episode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return path + "/" + shot.shotCode + "/" + (shot.shotVersion || "v001");
|
||||||
|
}
|
||||||
|
|
||||||
function ensureFolder(path) {
|
function ensureFolder(path) {
|
||||||
var folder = new Folder(path);
|
var folder = new Folder(path);
|
||||||
var parent;
|
var parent;
|
||||||
@@ -912,7 +933,7 @@ var SETTINGS_KEY = "cfg";
|
|||||||
disableLayerByName(comp, "UNG_VFX_OVERLAY");
|
disableLayerByName(comp, "UNG_VFX_OVERLAY");
|
||||||
disableLayerByName(comp, "_SHOW LUT");
|
disableLayerByName(comp, "_SHOW LUT");
|
||||||
|
|
||||||
folderPath = getShowExportRoot() + "/" + shotCode;
|
folderPath = getShotExportDir(shot);
|
||||||
if (!ensureFolder(folderPath)) {
|
if (!ensureFolder(folderPath)) {
|
||||||
addFailure(result, comp.name, "Could not create output folder");
|
addFailure(result, comp.name, "Could not create output folder");
|
||||||
continue;
|
continue;
|
||||||
@@ -1242,14 +1263,9 @@ var SETTINGS_KEY = "cfg";
|
|||||||
var mainComp;
|
var mainComp;
|
||||||
var previewComp;
|
var previewComp;
|
||||||
var outputPath;
|
var outputPath;
|
||||||
|
var folderPath;
|
||||||
|
|
||||||
app.beginUndoGroup("VFXReview Connector - Queue " + label);
|
app.beginUndoGroup("VFXReview Connector - Queue " + label);
|
||||||
if (!ensureFolder(getShowExportRoot())) {
|
|
||||||
app.endUndoGroup();
|
|
||||||
updateStatus(comps.length, "Could not create export folder.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < comps.length; i += 1) {
|
for (i = 0; i < comps.length; i += 1) {
|
||||||
shotCode = getShotCodeFromComp(comps[i]);
|
shotCode = getShotCodeFromComp(comps[i]);
|
||||||
updateStatus(comps.length, "Preparing " + label + " preview for " + shotCode + " (" + (i + 1) + " of " + comps.length + ")");
|
updateStatus(comps.length, "Preparing " + label + " preview for " + shotCode + " (" + (i + 1) + " of " + comps.length + ")");
|
||||||
@@ -1282,7 +1298,13 @@ var SETTINGS_KEY = "cfg";
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateStatus(comps.length, "Queueing " + label + " for " + shotCode + " (" + (i + 1) + " of " + comps.length + ")");
|
updateStatus(comps.length, "Queueing " + label + " for " + shotCode + " (" + (i + 1) + " of " + comps.length + ")");
|
||||||
outputPath = getShowExportRoot() + "/" + shotCode + "_cmp_TT_" + (apiData.shot.shotVersion || "v001") + "." + extension;
|
folderPath = getShotExportDir(apiData.shot);
|
||||||
|
if (!ensureFolder(folderPath)) {
|
||||||
|
addFailure(result, comps[i].name, "Could not create output folder");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
outputPath = folderPath + "/" + shotCode + "_cmp_TT_" + (apiData.shot.shotVersion || "v001") + "." + extension;
|
||||||
if (queueCompWithOutput(previewComp, templateName, outputPath)) {
|
if (queueCompWithOutput(previewComp, templateName, outputPath)) {
|
||||||
queued += 1;
|
queued += 1;
|
||||||
result.queued += 1;
|
result.queued += 1;
|
||||||
@@ -1323,7 +1345,7 @@ var SETTINGS_KEY = "cfg";
|
|||||||
disableLayerByName(comp, "UNG_VFX_OVERLAY");
|
disableLayerByName(comp, "UNG_VFX_OVERLAY");
|
||||||
disableLayerByName(comp, "_SHOW LUT");
|
disableLayerByName(comp, "_SHOW LUT");
|
||||||
|
|
||||||
folderPath = getShowExportRoot() + "/" + shotCode;
|
folderPath = getShotExportDir(shot);
|
||||||
if (!ensureFolder(folderPath)) {
|
if (!ensureFolder(folderPath)) {
|
||||||
addFailure(result, comp.name, "Could not create output folder");
|
addFailure(result, comp.name, "Could not create output folder");
|
||||||
continue;
|
continue;
|
||||||
@@ -1384,7 +1406,7 @@ var SETTINGS_KEY = "cfg";
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
exportFolder = new Folder(getShowExportRoot() + "/" + shot.shotCode);
|
exportFolder = new Folder(getShotExportDir(shot));
|
||||||
if (!exportFolder.exists) {
|
if (!exportFolder.exists) {
|
||||||
updateStatus(comps.length, "Export folder not found: " + exportFolder.fsName);
|
updateStatus(comps.length, "Export folder not found: " + exportFolder.fsName);
|
||||||
skipped += 1;
|
skipped += 1;
|
||||||
@@ -1596,7 +1618,7 @@ var SETTINGS_KEY = "cfg";
|
|||||||
expectedBaseName = shotCode + "_cmp_TT_" + (shot.shotVersion || "v001");
|
expectedBaseName = shotCode + "_cmp_TT_" + (shot.shotVersion || "v001");
|
||||||
exrOutputBase = shot.exrOutput || "";
|
exrOutputBase = shot.exrOutput || "";
|
||||||
|
|
||||||
sourceFolder = new Folder(getShowExportRoot() + "/" + shotCode);
|
sourceFolder = new Folder(getShotExportDir(shot));
|
||||||
if (!sourceFolder.exists) {
|
if (!sourceFolder.exists) {
|
||||||
addFailure(result, comp.name, "Source export folder not found: " + sourceFolder.fsName);
|
addFailure(result, comp.name, "Source export folder not found: " + sourceFolder.fsName);
|
||||||
continue;
|
continue;
|
||||||
@@ -2505,6 +2527,13 @@ var SETTINGS_KEY = "cfg";
|
|||||||
status === "VALIDATING" || status === "GENERATING_PREVIEW";
|
status === "VALIDATING" || status === "GENERATING_PREVIEW";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mirrors REGENERATABLE_STATUSES on the server: every state where the EXRs
|
||||||
|
// are known good, so only the preview needs rebuilding.
|
||||||
|
function isRegeneratableExportStatus(status) {
|
||||||
|
return status === "READY_FOR_QC" || status === "QC_FAILED" ||
|
||||||
|
status === "PREVIEW_FAILED";
|
||||||
|
}
|
||||||
|
|
||||||
function formatEtaShort(seconds) {
|
function formatEtaShort(seconds) {
|
||||||
var mins;
|
var mins;
|
||||||
var secs;
|
var secs;
|
||||||
@@ -2836,6 +2865,57 @@ var SETTINGS_KEY = "cfg";
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Rebuild the delivered MOV/MP4 after a slate/burn-in mistake: same version,
|
||||||
|
// same EXRs, freshly built slate. Slate text (description, scope, note)
|
||||||
|
// comes from the shot record, so it is fixed on the web app first — except
|
||||||
|
// the panel's Sub. Note field, which still wins as a per-export override.
|
||||||
|
function regenerateLatestPreview() {
|
||||||
|
var shotCode = getStatusShotCode();
|
||||||
|
var data;
|
||||||
|
var exportInfo;
|
||||||
|
var body = {};
|
||||||
|
var note;
|
||||||
|
var response;
|
||||||
|
|
||||||
|
if (!shotCode) {
|
||||||
|
setPipelineStatus("Select a comp or shot first");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
data = getLatestExportData(shotCode);
|
||||||
|
exportInfo = data ? data.export : null;
|
||||||
|
if (!exportInfo) {
|
||||||
|
setPipelineStatus(shotCode + " — no export to regenerate");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!isRegeneratableExportStatus(String(exportInfo.status))) {
|
||||||
|
setPipelineStatus(formatExportStatus(shotCode, exportInfo) +
|
||||||
|
" — preview can only be regenerated once the render is done");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!confirm("Rebuild the preview for " + shotCode + " " + exportInfo.versionString + "?\n\n" +
|
||||||
|
"The rendered EXRs are reused and the version number stays the same.\n" +
|
||||||
|
"The existing review version's media is replaced.")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (uiState.submissionNoteField) {
|
||||||
|
note = trimText(uiState.submissionNoteField.text);
|
||||||
|
if (note) {
|
||||||
|
body.submissionNote = note;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setPipelineStatus(shotCode + " " + exportInfo.versionString + " — regenerating preview...");
|
||||||
|
response = postJSON(CONFIG.baseUrl + "/api/ext/exports/" + exportInfo.id + "/regenerate-preview", body);
|
||||||
|
if (response.status === 200) {
|
||||||
|
setPipelineStatus(shotCode + " " + exportInfo.versionString + " — preview queued");
|
||||||
|
startExportPolling(shotCode);
|
||||||
|
} else {
|
||||||
|
setPipelineStatus("Regenerate failed: " +
|
||||||
|
((response.data && response.data.error) ? response.data.error : "HTTP " + response.status));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function buildUI(thisObjRef) {
|
function buildUI(thisObjRef) {
|
||||||
var win = (thisObjRef instanceof Panel) ? thisObjRef : new Window("palette", "VFXReview Connector", undefined, { resizeable: true });
|
var win = (thisObjRef instanceof Panel) ? thisObjRef : new Window("palette", "VFXReview Connector", undefined, { resizeable: true });
|
||||||
var bannerFile;
|
var bannerFile;
|
||||||
@@ -2847,9 +2927,11 @@ var SETTINGS_KEY = "cfg";
|
|||||||
var pipelinePanel;
|
var pipelinePanel;
|
||||||
var pipelineRow1;
|
var pipelineRow1;
|
||||||
var pipelineRow2;
|
var pipelineRow2;
|
||||||
|
var pipelineRow3;
|
||||||
var queueExportButton;
|
var queueExportButton;
|
||||||
var refreshExportButton;
|
var refreshExportButton;
|
||||||
var retryExportButton;
|
var retryExportButton;
|
||||||
|
var regeneratePreviewButton;
|
||||||
var buttonsPanel;
|
var buttonsPanel;
|
||||||
var btnRow1;
|
var btnRow1;
|
||||||
var btnRow2;
|
var btnRow2;
|
||||||
@@ -2984,6 +3066,16 @@ var SETTINGS_KEY = "cfg";
|
|||||||
refreshExportButton = pipelineRow2.add("button", undefined, "Refresh Status");
|
refreshExportButton = pipelineRow2.add("button", undefined, "Refresh Status");
|
||||||
retryExportButton = pipelineRow2.add("button", undefined, "Retry Export");
|
retryExportButton = pipelineRow2.add("button", undefined, "Retry Export");
|
||||||
|
|
||||||
|
pipelineRow3 = pipelinePanel.add("group");
|
||||||
|
pipelineRow3.orientation = "row";
|
||||||
|
pipelineRow3.alignChildren = ["fill", "center"];
|
||||||
|
pipelineRow3.spacing = 6;
|
||||||
|
regeneratePreviewButton = pipelineRow3.add("button", undefined, "Regenerate Previews");
|
||||||
|
regeneratePreviewButton.helpTip =
|
||||||
|
"Rebuild the MOV/MP4 slate and burn-ins for the delivered version.\n" +
|
||||||
|
"Reuses the rendered EXRs and keeps the version number. Slate text is\n" +
|
||||||
|
"re-read from the shot, so fix it on the web app's Slate tab first.";
|
||||||
|
|
||||||
buttonsPanel = scrollContent.add("panel", undefined, "Actions");
|
buttonsPanel = scrollContent.add("panel", undefined, "Actions");
|
||||||
buttonsPanel.orientation = "column";
|
buttonsPanel.orientation = "column";
|
||||||
buttonsPanel.alignChildren = ["fill", "top"];
|
buttonsPanel.alignChildren = ["fill", "top"];
|
||||||
@@ -3100,6 +3192,7 @@ var SETTINGS_KEY = "cfg";
|
|||||||
queueExportButton.onClick = queueExport;
|
queueExportButton.onClick = queueExport;
|
||||||
refreshExportButton.onClick = refreshExportStatus;
|
refreshExportButton.onClick = refreshExportStatus;
|
||||||
retryExportButton.onClick = retryLatestExport;
|
retryExportButton.onClick = retryLatestExport;
|
||||||
|
regeneratePreviewButton.onClick = regenerateLatestPreview;
|
||||||
refreshButton.onClick = refreshSelection;
|
refreshButton.onClick = refreshSelection;
|
||||||
fixNamesButton.onClick = fixCompNames;
|
fixNamesButton.onClick = fixCompNames;
|
||||||
overlayButton.onClick = addOverlay;
|
overlayButton.onClick = addOverlay;
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { isExtAuthorized } from "@/lib/render-pipeline/ext-auth";
|
||||||
|
import { toErrorResponse } from "@/lib/render-pipeline/errors";
|
||||||
|
import { regeneratePreview } from "@/lib/render-pipeline/preview";
|
||||||
|
|
||||||
|
// ── POST /api/ext/exports/{exportId}/regenerate-preview (E15b) ───────────────
|
||||||
|
//
|
||||||
|
// Rebuild the preview MOV/MP4 for an export that already delivered one, after a
|
||||||
|
// slate or burn-in mistake was caught. Reuses the validated EXRs and keeps the
|
||||||
|
// version number; slate text edited on the web app's Slate tab is picked up.
|
||||||
|
//
|
||||||
|
// Body (all optional):
|
||||||
|
// vfxScope per-export override; omit to re-read the shot's slate field
|
||||||
|
// submissionNote same
|
||||||
|
// note audit note for the ExportEvent
|
||||||
|
|
||||||
|
export async function POST(
|
||||||
|
req: NextRequest,
|
||||||
|
{ params }: { params: Promise<{ exportId: string }> }
|
||||||
|
) {
|
||||||
|
if (!isExtAuthorized(req)) {
|
||||||
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||||
|
}
|
||||||
|
const { exportId } = await params;
|
||||||
|
|
||||||
|
let body: {
|
||||||
|
vfxScope?: string | null;
|
||||||
|
submissionNote?: string | null;
|
||||||
|
note?: string;
|
||||||
|
} = {};
|
||||||
|
try {
|
||||||
|
const parsed = await req.json();
|
||||||
|
if (parsed && typeof parsed === "object") body = parsed;
|
||||||
|
} catch {
|
||||||
|
// empty body is fine — everything falls back to the shot's slate fields
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const result = await regeneratePreview(exportId, {
|
||||||
|
...(body.vfxScope !== undefined ? { vfxScope: body.vfxScope } : {}),
|
||||||
|
...(body.submissionNote !== undefined ? { submissionNote: body.submissionNote } : {}),
|
||||||
|
note: typeof body.note === "string" ? body.note : "Regenerate preview from AE panel",
|
||||||
|
});
|
||||||
|
return NextResponse.json(result);
|
||||||
|
} catch (err) {
|
||||||
|
const { body: errBody, status } = toErrorResponse(err);
|
||||||
|
return NextResponse.json(errBody, { status });
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,7 @@ function isAuthorized(req: NextRequest): boolean {
|
|||||||
//
|
//
|
||||||
// Query params (all optional):
|
// Query params (all optional):
|
||||||
// episode e.g. 108
|
// episode e.g. 108
|
||||||
|
// scene e.g. 022
|
||||||
// sequence e.g. 004
|
// sequence e.g. 004
|
||||||
// status e.g. IN_PROGRESS
|
// status e.g. IN_PROGRESS
|
||||||
// page (default 1)
|
// page (default 1)
|
||||||
@@ -60,6 +61,7 @@ export async function GET(
|
|||||||
where: {
|
where: {
|
||||||
projectId: project.id,
|
projectId: project.id,
|
||||||
...(episode ? { episode } : {}),
|
...(episode ? { episode } : {}),
|
||||||
|
...(scene ? { scene } : {}),
|
||||||
...(sequence ? { sequence } : {}),
|
...(sequence ? { sequence } : {}),
|
||||||
...(status ? { status: status as never } : {}),
|
...(status ? { status: status as never } : {}),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
import { describe, it, expect } from "vitest";
|
||||||
|
import { nextTaskTitle } from "./preview";
|
||||||
|
|
||||||
|
describe("nextTaskTitle", () => {
|
||||||
|
it("swaps an existing version suffix", () => {
|
||||||
|
expect(nextTaskTitle("UNG_102_019_010_cmp_TT_v004", "v005")).toBe(
|
||||||
|
"UNG_102_019_010_cmp_TT_v005"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("is idempotent when the title already matches", () => {
|
||||||
|
expect(nextTaskTitle("UNG_102_019_010_cmp_TT_v005", "v005")).toBe(
|
||||||
|
"UNG_102_019_010_cmp_TT_v005"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("appends when the title carries no version yet", () => {
|
||||||
|
expect(nextTaskTitle("UNG_102_019_010_cmp_TT", "v005")).toBe(
|
||||||
|
"UNG_102_019_010_cmp_TT_v005"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("only touches a trailing suffix, not a version inside the name", () => {
|
||||||
|
expect(nextTaskTitle("UNG_v001_019_010_cmp_TT_v004", "v005")).toBe(
|
||||||
|
"UNG_v001_019_010_cmp_TT_v005"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("handles double-digit and uppercase suffixes", () => {
|
||||||
|
expect(nextTaskTitle("SHOT_cmp_TT_V12", "v013")).toBe("SHOT_cmp_TT_v013");
|
||||||
|
});
|
||||||
|
});
|
||||||
+196
-35
@@ -1,4 +1,4 @@
|
|||||||
import { Prisma } from "@prisma/client";
|
import { ExportStatus, Prisma } from "@prisma/client";
|
||||||
import { db } from "@/lib/db";
|
import { db } from "@/lib/db";
|
||||||
import { PipelineError } from "./errors";
|
import { PipelineError } from "./errors";
|
||||||
import { applyTransition } from "./transitions";
|
import { applyTransition } from "./transitions";
|
||||||
@@ -68,7 +68,14 @@ type ExportForPreview = {
|
|||||||
export async function buildPreviewManifest(exportRow: ExportForPreview): Promise<PreviewManifest> {
|
export async function buildPreviewManifest(exportRow: ExportForPreview): Promise<PreviewManifest> {
|
||||||
const shot = await db.shot.findUnique({
|
const shot = await db.shot.findUnique({
|
||||||
where: { id: exportRow.shotId },
|
where: { id: exportRow.shotId },
|
||||||
select: { shotCode: true, episode: true, scene: true, description: true, notes: true },
|
select: {
|
||||||
|
shotCode: true,
|
||||||
|
episode: true,
|
||||||
|
scene: true,
|
||||||
|
description: true,
|
||||||
|
notes: true,
|
||||||
|
slateDescription: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!shot) throw new PipelineError(404, "Shot not found for export");
|
if (!shot) throw new PipelineError(404, "Shot not found for export");
|
||||||
|
|
||||||
@@ -98,7 +105,10 @@ export async function buildPreviewManifest(exportRow: ExportForPreview): Promise
|
|||||||
slate: {
|
slate: {
|
||||||
versionName: base,
|
versionName: base,
|
||||||
date: slateDate(),
|
date: slateDate(),
|
||||||
description: shot.description,
|
// The slate's own description is authored on the Shot's Slate tab and
|
||||||
|
// falls back to the general shot description — the same precedence the
|
||||||
|
// tab shows as its placeholder.
|
||||||
|
description: shot.slateDescription ?? shot.description,
|
||||||
notes: shot.notes,
|
notes: shot.notes,
|
||||||
shotCode: shot.shotCode,
|
shotCode: shot.shotCode,
|
||||||
episode: shot.episode,
|
episode: shot.episode,
|
||||||
@@ -129,6 +139,16 @@ export async function createPreviewJob(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* `UNG_102_019_010_cmp_TT_v004` + v005 → `UNG_102_019_010_cmp_TT_v005`.
|
||||||
|
* Mirrors `nextExrOutputBase` (exports.ts) so the task title, the EXR base and
|
||||||
|
* the preview filename all carry the same version suffix.
|
||||||
|
*/
|
||||||
|
export function nextTaskTitle(current: string, versionString: string): string {
|
||||||
|
if (/_v\d+$/i.test(current)) return current.replace(/_v\d+$/i, `_${versionString}`);
|
||||||
|
return `${current}_${versionString}`;
|
||||||
|
}
|
||||||
|
|
||||||
export interface FinalizeInput {
|
export interface FinalizeInput {
|
||||||
artifacts?: {
|
artifacts?: {
|
||||||
deliveryMovPath?: string;
|
deliveryMovPath?: string;
|
||||||
@@ -167,6 +187,7 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
|||||||
return {
|
return {
|
||||||
export: { id: exportRow.id, status: exportRow.status },
|
export: { id: exportRow.id, status: exportRow.status },
|
||||||
version: { id: exportRow.versionId },
|
version: { id: exportRow.versionId },
|
||||||
|
task: null,
|
||||||
alreadyApplied: true,
|
alreadyApplied: true,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -186,45 +207,90 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
|||||||
});
|
});
|
||||||
|
|
||||||
let versionId: string | null = null;
|
let versionId: string | null = null;
|
||||||
|
let versionReplaced = false;
|
||||||
if (artifacts.previewMovKey) {
|
if (artifacts.previewMovKey) {
|
||||||
// Version numbering stays monotonic for the task (existing review flows
|
const mediaFields = {
|
||||||
// rely on the newest version having the highest number) while matching
|
fileUrl: `/api/files/${artifacts.previewMovKey}`,
|
||||||
// the export version whenever it is ahead.
|
fileName: media.fileName ?? `${exportRow.versionString}.mp4`,
|
||||||
const taskMax = exportRow.taskId
|
mimeType: "video/mp4",
|
||||||
? await tx.version.aggregate({
|
thumbnailUrl: artifacts.thumbnailKey ? `/api/files/${artifacts.thumbnailKey}` : undefined,
|
||||||
where: { taskId: exportRow.taskId },
|
fps: media.fps ?? exportRow.fps,
|
||||||
_max: { versionNumber: true },
|
frameCount: media.frameCount ?? exportRow.frameEnd - exportRow.frameStart + 1,
|
||||||
})
|
width: media.width ?? exportRow.width,
|
||||||
: { _max: { versionNumber: null as number | null } };
|
height: media.height ?? exportRow.height,
|
||||||
const versionNumber = Math.max((taskMax._max.versionNumber ?? 0) + 1, exportRow.versionNumber);
|
};
|
||||||
|
|
||||||
|
// Regenerating a preview (T11b) re-delivers the *same* export version, so
|
||||||
|
// it replaces the media on the Version already registered rather than
|
||||||
|
// stacking a second row: the version number stays put and any notes or
|
||||||
|
// annotations reviewers left on it survive the reslate.
|
||||||
|
const existing = exportRow.versionId
|
||||||
|
? await tx.version.findUnique({ where: { id: exportRow.versionId }, select: { id: true } })
|
||||||
|
: null;
|
||||||
|
|
||||||
|
if (existing) {
|
||||||
|
await tx.version.update({
|
||||||
|
where: { id: existing.id },
|
||||||
|
data: { ...mediaFields, isLatest: true },
|
||||||
|
});
|
||||||
|
versionId = existing.id;
|
||||||
|
versionReplaced = true;
|
||||||
|
} else {
|
||||||
|
// Version numbering stays monotonic for the task (existing review flows
|
||||||
|
// rely on the newest version having the highest number) while matching
|
||||||
|
// the export version whenever it is ahead.
|
||||||
|
const taskMax = exportRow.taskId
|
||||||
|
? await tx.version.aggregate({
|
||||||
|
where: { taskId: exportRow.taskId },
|
||||||
|
_max: { versionNumber: true },
|
||||||
|
})
|
||||||
|
: { _max: { versionNumber: null as number | null } };
|
||||||
|
const versionNumber = Math.max((taskMax._max.versionNumber ?? 0) + 1, exportRow.versionNumber);
|
||||||
|
|
||||||
|
const version = await tx.version.create({
|
||||||
|
data: {
|
||||||
|
...mediaFields,
|
||||||
|
versionNumber,
|
||||||
|
shotId: exportRow.shotId,
|
||||||
|
taskId: exportRow.taskId,
|
||||||
|
artistId: exportRow.submittedById,
|
||||||
|
notes: `Pipeline render ${exportRow.versionString} (internal only)`,
|
||||||
|
isLatest: true,
|
||||||
|
isClientVisible: false, // never shared to the client portal (§10.0)
|
||||||
|
},
|
||||||
|
});
|
||||||
|
versionId = version.id;
|
||||||
|
}
|
||||||
|
|
||||||
if (exportRow.taskId) {
|
if (exportRow.taskId) {
|
||||||
await tx.version.updateMany({
|
await tx.version.updateMany({
|
||||||
where: { taskId: exportRow.taskId },
|
where: { taskId: exportRow.taskId, id: { not: versionId } },
|
||||||
data: { isLatest: false },
|
data: { isLatest: false },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const version = await tx.version.create({
|
// The task title carries the version it is showing (house convention:
|
||||||
data: {
|
// "UNG_102_019_010_cmp_TT_v004"). The preview just uploaded *is* the task's
|
||||||
versionNumber,
|
// new latest version, so the title has to follow the file — the same rename
|
||||||
shotId: exportRow.shotId,
|
// the manual batch upload does on "rename-and-upload".
|
||||||
taskId: exportRow.taskId,
|
let taskTitle: string | null = null;
|
||||||
artistId: exportRow.submittedById,
|
let taskRenamed = false;
|
||||||
fileUrl: `/api/files/${artifacts.previewMovKey}`,
|
if (versionId && exportRow.taskId) {
|
||||||
fileName: media.fileName ?? `${exportRow.versionString}.mp4`,
|
const task = await tx.task.findUnique({
|
||||||
mimeType: "video/mp4",
|
where: { id: exportRow.taskId },
|
||||||
thumbnailUrl: artifacts.thumbnailKey ? `/api/files/${artifacts.thumbnailKey}` : undefined,
|
select: { title: true },
|
||||||
fps: media.fps ?? exportRow.fps,
|
|
||||||
frameCount: media.frameCount ?? exportRow.frameEnd - exportRow.frameStart + 1,
|
|
||||||
width: media.width ?? exportRow.width,
|
|
||||||
height: media.height ?? exportRow.height,
|
|
||||||
notes: `Pipeline render ${exportRow.versionString} (internal only)`,
|
|
||||||
isLatest: true,
|
|
||||||
isClientVisible: false, // never shared to the client portal (§10.0)
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
versionId = version.id;
|
if (task) {
|
||||||
|
taskTitle = nextTaskTitle(task.title, exportRow.versionString);
|
||||||
|
taskRenamed = taskTitle !== task.title;
|
||||||
|
if (taskRenamed) {
|
||||||
|
await tx.task.update({
|
||||||
|
where: { id: exportRow.taskId },
|
||||||
|
data: { title: taskTitle },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const updated = await applyTransition(
|
const updated = await applyTransition(
|
||||||
@@ -234,7 +300,14 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
|||||||
{
|
{
|
||||||
type: "WORKER",
|
type: "WORKER",
|
||||||
id: machineId,
|
id: machineId,
|
||||||
note: `Preview complete in ${body.renderStats?.previewSeconds ?? "?"}s${versionId ? " — review version created" : " — no preview media reported"}`,
|
note:
|
||||||
|
`Preview complete in ${body.renderStats?.previewSeconds ?? "?"}s` +
|
||||||
|
(versionId
|
||||||
|
? versionReplaced
|
||||||
|
? " — review version media replaced"
|
||||||
|
: " — review version created"
|
||||||
|
: " — no preview media reported") +
|
||||||
|
(taskRenamed ? ` — task renamed to ${taskTitle}` : ""),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
...(versionId ? { versionId } : {}),
|
...(versionId ? { versionId } : {}),
|
||||||
@@ -247,7 +320,8 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
export: { id: updated.id, status: updated.status },
|
export: { id: updated.id, status: updated.status },
|
||||||
version: versionId ? { id: versionId } : null,
|
version: versionId ? { id: versionId, replaced: versionReplaced } : null,
|
||||||
|
task: exportRow.taskId ? { id: exportRow.taskId, title: taskTitle, renamed: taskRenamed } : null,
|
||||||
alreadyApplied: false,
|
alreadyApplied: false,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@@ -293,3 +367,90 @@ export async function retryPreview(exportId: string, actorId?: string) {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Statuses a preview can be regenerated from — every state where the EXRs are known good. */
|
||||||
|
const REGENERATABLE_STATUSES: ExportStatus[] = ["READY_FOR_QC", "QC_FAILED", "PREVIEW_FAILED"];
|
||||||
|
|
||||||
|
export interface RegeneratePreviewInput {
|
||||||
|
/** Per-export override; omitted → re-read from the shot's slate fields. */
|
||||||
|
vfxScope?: string | null;
|
||||||
|
submissionNote?: string | null;
|
||||||
|
actorId?: string;
|
||||||
|
note?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* T11b — rebuild the preview for an export that already delivered one, after a
|
||||||
|
* slate or burn-in mistake was spotted in QC.
|
||||||
|
*
|
||||||
|
* Re-runs the *whole* preview stage rather than patching anything: the manifest
|
||||||
|
* is rebuilt from scratch, so the shot code, episode/scene, frame count, slate
|
||||||
|
* date and burn-ins are all re-derived from current data exactly as they are on
|
||||||
|
* a first-time preview. The validated EXRs are reused and the version number is
|
||||||
|
* untouched — this re-delivers the same version, it does not make a new one.
|
||||||
|
*
|
||||||
|
* Slate text authored on the web app's Slate tab (description, VFX scope,
|
||||||
|
* submission note) is picked up here: `vfxScope` and `submissionNote` are
|
||||||
|
* frozen onto the Export at submission time, so regenerating refreshes that
|
||||||
|
* snapshot from the shot unless the caller passes an explicit override.
|
||||||
|
*/
|
||||||
|
export async function regeneratePreview(exportId: string, input: RegeneratePreviewInput = {}) {
|
||||||
|
const maxAttempts = await getConfigNumber("render.maxAttempts");
|
||||||
|
|
||||||
|
return db.$transaction(async (tx) => {
|
||||||
|
const exportRow = await tx.export.findUnique({ where: { id: exportId } });
|
||||||
|
if (!exportRow) throw new PipelineError(404, "Export not found");
|
||||||
|
if (!REGENERATABLE_STATUSES.includes(exportRow.status)) {
|
||||||
|
throw new PipelineError(
|
||||||
|
409,
|
||||||
|
`Export is ${exportRow.status} — a preview can only be regenerated from ${REGENERATABLE_STATUSES.join(", ")}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const shot = await tx.shot.findUniqueOrThrow({
|
||||||
|
where: { id: exportRow.shotId },
|
||||||
|
select: { slateVfxScope: true, slateSubmissionNote: true },
|
||||||
|
});
|
||||||
|
// Same precedence as createExport: explicit override → shot's slate field.
|
||||||
|
const vfxScope = input.vfxScope !== undefined ? input.vfxScope : (shot.slateVfxScope ?? null);
|
||||||
|
const submissionNote =
|
||||||
|
input.submissionNote !== undefined ? input.submissionNote : (shot.slateSubmissionNote ?? null);
|
||||||
|
|
||||||
|
const refreshed = { ...exportRow, vfxScope, submissionNote };
|
||||||
|
const manifest = await buildPreviewManifest(refreshed);
|
||||||
|
|
||||||
|
const last = await tx.renderJob.findFirst({
|
||||||
|
where: { exportId, type: "PREVIEW_ONLY" },
|
||||||
|
orderBy: { attempt: "desc" },
|
||||||
|
});
|
||||||
|
|
||||||
|
const job = await tx.renderJob.create({
|
||||||
|
data: {
|
||||||
|
type: "PREVIEW_ONLY",
|
||||||
|
exportId,
|
||||||
|
attempt: (last?.attempt ?? 0) + 1,
|
||||||
|
maxAttempts,
|
||||||
|
priority: last?.priority ?? 50,
|
||||||
|
manifest: manifest as unknown as Prisma.InputJsonValue,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const updated = await applyTransition(
|
||||||
|
tx,
|
||||||
|
exportRow,
|
||||||
|
"GENERATING_PREVIEW",
|
||||||
|
{
|
||||||
|
type: "USER",
|
||||||
|
id: input.actorId,
|
||||||
|
note: input.note ?? `Regenerate preview (attempt ${job.attempt})`,
|
||||||
|
},
|
||||||
|
{ vfxScope, submissionNote }
|
||||||
|
);
|
||||||
|
|
||||||
|
return {
|
||||||
|
export: { id: updated.id, status: updated.status },
|
||||||
|
renderJob: { id: job.id, attempt: job.attempt },
|
||||||
|
slate: { vfxScope, submissionNote, description: manifest.slate.description },
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -24,8 +24,11 @@ export const EXPORT_TRANSITIONS: Record<ExportStatus, ExportStatus[]> = {
|
|||||||
VALIDATION_FAILED: ["QUEUED", "SUPERSEDED"],
|
VALIDATION_FAILED: ["QUEUED", "SUPERSEDED"],
|
||||||
GENERATING_PREVIEW: ["PREVIEW_FAILED", "READY_FOR_QC"],
|
GENERATING_PREVIEW: ["PREVIEW_FAILED", "READY_FOR_QC"],
|
||||||
PREVIEW_FAILED: ["GENERATING_PREVIEW", "SUPERSEDED"],
|
PREVIEW_FAILED: ["GENERATING_PREVIEW", "SUPERSEDED"],
|
||||||
READY_FOR_QC: ["QC_FAILED", "READY_FOR_DELIVERY", "SUPERSEDED"],
|
// GENERATING_PREVIEW: a slate/burn-in mistake is caught *after* a successful
|
||||||
QC_FAILED: ["SUPERSEDED"],
|
// preview, so the preview stage must be re-runnable without re-rendering the
|
||||||
|
// validated EXRs or burning a version number (T11b).
|
||||||
|
READY_FOR_QC: ["GENERATING_PREVIEW", "QC_FAILED", "READY_FOR_DELIVERY", "SUPERSEDED"],
|
||||||
|
QC_FAILED: ["GENERATING_PREVIEW", "SUPERSEDED"],
|
||||||
READY_FOR_DELIVERY: ["PACKAGED", "SUPERSEDED"],
|
READY_FOR_DELIVERY: ["PACKAGED", "SUPERSEDED"],
|
||||||
PACKAGED: ["DELIVERED"],
|
PACKAGED: ["DELIVERED"],
|
||||||
DELIVERED: ["ARCHIVED"],
|
DELIVERED: ["ARCHIVED"],
|
||||||
|
|||||||
Reference in New Issue
Block a user