Files
twotalesanimation 9660cdc21c
Deploy / deploy (push) Successful in 3m23s
feat(review): High quality playback switch and per-version ProRes download
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>
2026-09-22 16:32:18 +02:00

58 lines
2.0 KiB
TypeScript

import { NextRequest, NextResponse } from "next/server";
import { db } from "@/lib/db";
import { validateReviewToken } from "@/lib/review-auth";
import { generateHetznerDownloadUrl } from "@/lib/storage";
import { clientHighResFilename } from "@/lib/shot-code";
/**
* GET /api/client/[token]/versions/[versionId]/highres/download
* The version's ProRes, for a client reviewer: same visibility rule as the
* version itself (GET ../route.ts), and named with the client's shot code.
*/
export async function GET(
req: NextRequest,
{ params }: { params: Promise<{ token: string; versionId: string }> }
) {
const { token, versionId } = await params;
const result = await validateReviewToken(token, req);
if (result.type !== "ok") {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
const version = await db.version.findUnique({
where: { id: versionId },
select: {
highResKey: true,
highResFilename: true,
isClientVisible: true,
shot: { select: { projectId: true, shotCode: true, clientCode: true } },
task: {
select: {
projectId: true,
shot: { select: { shotCode: true, clientCode: true } },
},
},
},
});
const projectId = version?.shot?.projectId ?? version?.task?.projectId;
if (!version || projectId !== result.session.projectId) {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
// Task-only versions need explicit sharing, as in the version route
if (!version.shot && !version.isClientVisible) {
return NextResponse.json({ error: "Not found" }, { status: 404 });
}
if (!version.highResKey) {
return NextResponse.json({ error: "No high-res file available" }, { status: 404 });
}
const shot = version.shot ?? version.task?.shot ?? null;
const url = await generateHetznerDownloadUrl(
version.highResKey,
clientHighResFilename(version.highResFilename ?? "high-res.mov", shot)
);
return NextResponse.json({ url });
}