feat(review): High quality playback switch and per-version ProRes download
Deploy / deploy (push) Successful in 3m23s
Deploy / deploy (push) Successful in 3m23s
Worker 1.7.0 (preview.highQuality, default on) now, after the AE render: - encodes a High quality MP4 from the delivery MOV (full-res H.264 High, CRF 14 capped at 100 Mbps) -> Version.hqFileUrl - uploads the MOV itself -> Version.highResKey/Filename/Size Both best-effort (the preview never fails over them), with a lease keep-alive during the long encode/uploads; the export timeline records what was attached. Player: HQ switch when a High quality source exists; keeps frame, play state, speed and zoom, remembered per browser, falls back to Standard if the file won't load. ProRes itself stays download-only (browser support). Downloads: the client portal's High Res button serves the version's ProRes (client-code filename), falling back to the shot's manual file; staff get a ProRes button on the review page. Housekeeping (lib/render-pipeline/high-res.ts): HQ MP4 + ProRes are kept while a version is latest, client-shared, approved or younger than preview.highResRetentionDays (14); otherwise deleted from storage. Runs per task after finalize and hourly from the reaper; deleting a version or a reslate removes its files. The Standard MP4 is never touched. Also: ProRes/Handles top-bar buttons go icon-only below lg so they don't overlap the version selector. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import { applyTransition } from "./transitions";
|
||||
import { getConfigNumber, getPreviewConfig } from "./config";
|
||||
import { resolveProjectTemplates, autoShotThumbnailEnabled } from "./project-templates";
|
||||
import { clientShotCode } from "@/lib/shot-code";
|
||||
import { deleteStorageKeys, highResStorageKeys, pruneHighResForTask } from "./high-res";
|
||||
import { recalcShotStatus, clearStaleShotApproval } from "@/lib/shot-status";
|
||||
import { renderOutputBase } from "./exports";
|
||||
|
||||
@@ -35,6 +36,8 @@ export interface PreviewManifest {
|
||||
mp4Output: string;
|
||||
slateScopeProp: string;
|
||||
slateSubmissionProp: string;
|
||||
/** Also encode the High quality MP4 and upload the MOV (worker >= 1.7.0). */
|
||||
highQuality: boolean;
|
||||
slate: {
|
||||
versionName: string;
|
||||
date: string;
|
||||
@@ -122,6 +125,7 @@ export async function buildPreviewManifest(exportRow: ExportForPreview): Promise
|
||||
mp4Output: `${exportRow.outputDir}/${base}.mp4`,
|
||||
slateScopeProp: cfg.slateScopeProp,
|
||||
slateSubmissionProp: cfg.slateSubmissionProp,
|
||||
highQuality: cfg.highQuality,
|
||||
slate: {
|
||||
versionName: clientBase,
|
||||
date: slateDate(),
|
||||
@@ -295,6 +299,12 @@ export interface FinalizeInput {
|
||||
thumbnailKey?: string;
|
||||
metadataKey?: string;
|
||||
logFileKey?: string;
|
||||
/** High-bitrate full-res MP4 encoded from the MOV (worker >= 1.7.0). */
|
||||
hqPreviewKey?: string | null;
|
||||
/** The delivery MOV itself, uploaded as the version's High Res file. */
|
||||
highResKey?: string | null;
|
||||
highResFileName?: string | null;
|
||||
highResSize?: number | null;
|
||||
};
|
||||
renderStats?: { renderSeconds?: number; previewSeconds?: number };
|
||||
media?: {
|
||||
@@ -318,6 +328,19 @@ export interface FinalizeInput {
|
||||
* resurface in the review flow or the client portal.
|
||||
*/
|
||||
export async function finalizePreview(jobId: string, machineId: string, body: FinalizeInput) {
|
||||
const { replacedHighRes, housekeepTaskId, ...outcome } = await finalizePreviewTx(jobId, machineId, body);
|
||||
// Storage is only touched once the transaction has committed: a rollback
|
||||
// must never leave a Version pointing at a deleted file.
|
||||
await deleteStorageKeys(replacedHighRes);
|
||||
if (housekeepTaskId) {
|
||||
await pruneHighResForTask(housekeepTaskId).catch((err) =>
|
||||
console.error("[high-res] housekeeping after finalize failed", err)
|
||||
);
|
||||
}
|
||||
return outcome;
|
||||
}
|
||||
|
||||
async function finalizePreviewTx(jobId: string, machineId: string, body: FinalizeInput) {
|
||||
return db.$transaction(async (tx) => {
|
||||
const job = await tx.renderJob.findUnique({
|
||||
where: { id: jobId },
|
||||
@@ -336,6 +359,8 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
version: { id: exportRow.versionId },
|
||||
task: null,
|
||||
alreadyApplied: true,
|
||||
replacedHighRes: [] as string[],
|
||||
housekeepTaskId: null as string | null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -354,6 +379,7 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
});
|
||||
|
||||
let versionId: string | null = null;
|
||||
let replacedHighRes: string[] = [];
|
||||
let versionReplaced = false;
|
||||
let versionCreated = false;
|
||||
let inheritedApproval: string | null = null;
|
||||
@@ -377,6 +403,16 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
typeof media.pictureStartSeconds === "number" && media.pictureStartSeconds >= 0
|
||||
? Math.round(media.pictureStartSeconds * fps)
|
||||
: null,
|
||||
// High quality + ProRes: whatever this build produced. Absent means
|
||||
// the worker skipped or failed them (never fatal) — Standard only.
|
||||
hqFileUrl: artifacts.hqPreviewKey ? `/api/files/${artifacts.hqPreviewKey}` : null,
|
||||
highResKey: artifacts.highResKey ?? null,
|
||||
highResFilename: artifacts.highResKey ? (artifacts.highResFileName ?? null) : null,
|
||||
highResSize:
|
||||
artifacts.highResKey && typeof artifacts.highResSize === "number"
|
||||
? BigInt(Math.round(artifacts.highResSize))
|
||||
: null,
|
||||
highResPrunedAt: null,
|
||||
};
|
||||
|
||||
// Regenerating a preview (T11b) re-delivers the *same* export version, so
|
||||
@@ -384,10 +420,18 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
// 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 } })
|
||||
? await tx.version.findUnique({
|
||||
where: { id: exportRow.versionId },
|
||||
select: { id: true, hqFileUrl: true, highResKey: true },
|
||||
})
|
||||
: null;
|
||||
|
||||
if (existing) {
|
||||
// The reslate replaces the high-quality files too; the old ones would
|
||||
// otherwise sit in storage with nothing pointing at them.
|
||||
replacedHighRes = highResStorageKeys(existing).filter(
|
||||
(k) => k !== artifacts.highResKey && k !== artifacts.hqPreviewKey
|
||||
);
|
||||
await tx.version.update({
|
||||
where: { id: existing.id },
|
||||
data: { ...mediaFields, isLatest: true },
|
||||
@@ -555,7 +599,8 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
: " — no preview media reported") +
|
||||
(taskRenamed ? ` — task renamed to ${taskTitle}` : "") +
|
||||
(taskStatusMoved ? " — task moved to INTERNAL_REVIEW" : "") +
|
||||
thumbnailNote,
|
||||
thumbnailNote +
|
||||
(versionId ? highResNote(artifacts) : ""),
|
||||
},
|
||||
{
|
||||
...(versionId ? { versionId } : {}),
|
||||
@@ -571,10 +616,22 @@ export async function finalizePreview(jobId: string, machineId: string, body: Fi
|
||||
version: versionId ? { id: versionId, replaced: versionReplaced } : null,
|
||||
task: exportRow.taskId ? { id: exportRow.taskId, title: taskTitle, renamed: taskRenamed } : null,
|
||||
alreadyApplied: false,
|
||||
replacedHighRes,
|
||||
housekeepTaskId: versionId ? exportRow.taskId : null,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/** Timeline wording for what high-quality media this build attached. */
|
||||
function highResNote(artifacts: NonNullable<FinalizeInput["artifacts"]>): string {
|
||||
const hq = !!artifacts.hqPreviewKey;
|
||||
const mov = !!artifacts.highResKey;
|
||||
if (hq && mov) return " — High quality MP4 and ProRes attached";
|
||||
if (hq) return " — High quality MP4 attached (ProRes upload failed or skipped)";
|
||||
if (mov) return " — ProRes attached (High quality encode failed or skipped)";
|
||||
return " — no High quality/ProRes (disabled, worker < 1.7.0, or both failed — see the worker log)";
|
||||
}
|
||||
|
||||
/** T11 — retry the preview stage only; validated EXRs are left alone. */
|
||||
export async function retryPreview(exportId: string, actorId?: string) {
|
||||
const maxAttempts = await getConfigNumber("render.maxAttempts");
|
||||
|
||||
Reference in New Issue
Block a user