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:
@@ -43,6 +43,7 @@ interface PlaylistVersion {
|
||||
posterUrl: string | null;
|
||||
fps: number;
|
||||
frameCount?: number | null;
|
||||
hqFileUrl?: string | null;
|
||||
handleHead?: number | null;
|
||||
handleTail?: number | null;
|
||||
pictureStartFrame?: number | null;
|
||||
@@ -281,6 +282,7 @@ export function PlaylistClient({ projects, userRole }: PlaylistClientProps) {
|
||||
comments={[]}
|
||||
annotations={[]}
|
||||
handles={activeShot.latestVersion}
|
||||
hqVideoUrl={activeShot.latestVersion.hqFileUrl}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex-1 flex flex-col items-center justify-center gap-3 text-zinc-600">
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
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 });
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { db } from "@/lib/db";
|
||||
import { validateReviewToken, findReviewUser, ownsComment } from "@/lib/review-auth";
|
||||
import { clientShotCode, clientTaskTitle } from "@/lib/shot-code";
|
||||
import { clientHighResFilename, clientShotCode, clientTaskTitle } from "@/lib/shot-code";
|
||||
|
||||
/** GET /api/client/[token]/versions/[versionId] — returns version + comments for client portal */
|
||||
export async function GET(
|
||||
@@ -95,13 +95,21 @@ export async function GET(
|
||||
// The shot the title and breadcrumb are drawn from — either relation.
|
||||
const namingShot = version.shot ?? ((version.task as any)?.shot ?? null);
|
||||
|
||||
// High Res: this version's own ProRes (uploaded by the render worker) wins;
|
||||
// the shot's manually uploaded file is the fallback for older versions.
|
||||
const versionHighRes = !!version.highResKey;
|
||||
const serializedVersion = {
|
||||
...version,
|
||||
fileSize: version.fileSize?.toString() ?? null,
|
||||
highResKey: undefined, // never expose a storage key
|
||||
highResSize: version.highResSize?.toString() ?? null,
|
||||
// Top-level high-res fields so the client works for both shot and task versions
|
||||
hasHighRes: !!(highResShot?.highResKey),
|
||||
highResShotId: highResShot?.highResKey ? (highResShot.id ?? null) : null,
|
||||
highResFilename: highResShot?.highResFilename ?? null,
|
||||
hasHighRes: versionHighRes || !!(highResShot?.highResKey),
|
||||
highResSource: versionHighRes ? "version" : highResShot?.highResKey ? "shot" : null,
|
||||
highResShotId: !versionHighRes && highResShot?.highResKey ? (highResShot.id ?? null) : null,
|
||||
highResFilename: versionHighRes
|
||||
? clientHighResFilename(version.highResFilename ?? "high-res.mov", namingShot)
|
||||
: highResShot?.highResFilename ?? null,
|
||||
// Expose only whether a high-res file exists on the shot relation, never the storage key
|
||||
shot: version.shot
|
||||
? {
|
||||
|
||||
@@ -9,13 +9,15 @@ import { generateHetznerPresignedUploadUrl, sanitizeFileName } from "@/lib/stora
|
||||
//
|
||||
// Presigned upload URL for worker artifacts. Kinds map to the existing object
|
||||
// storage folder layout: preview → videos/, thumbnail → image/,
|
||||
// metadata/log → renders/.
|
||||
// metadata/log → renders/, highres (the delivery MOV) → highres/ beside the
|
||||
// manually uploaded High Res files.
|
||||
|
||||
const KIND_FOLDERS: Record<string, string> = {
|
||||
preview: "videos",
|
||||
thumbnail: "image",
|
||||
metadata: "renders",
|
||||
log: "renders",
|
||||
highres: "highres",
|
||||
};
|
||||
|
||||
export async function POST(
|
||||
|
||||
@@ -51,6 +51,7 @@ export async function GET(req: NextRequest) {
|
||||
posterUrl: true,
|
||||
fps: true,
|
||||
frameCount: true,
|
||||
hqFileUrl: true,
|
||||
handleHead: true,
|
||||
handleTail: true,
|
||||
pictureStartFrame: true,
|
||||
@@ -90,6 +91,7 @@ export async function GET(req: NextRequest) {
|
||||
posterUrl: latest.posterUrl,
|
||||
fps: latest.fps,
|
||||
frameCount: latest.frameCount,
|
||||
hqFileUrl: latest.hqFileUrl,
|
||||
handleHead: latest.handleHead,
|
||||
handleTail: latest.handleTail,
|
||||
pictureStartFrame: latest.pictureStartFrame,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { auth } from "@/auth";
|
||||
import { db } from "@/lib/db";
|
||||
import { generateHetznerDownloadUrl } from "@/lib/storage";
|
||||
|
||||
/**
|
||||
* GET /api/versions/[versionId]/highres/download — short-lived presigned URL
|
||||
* for this version's ProRes (the delivery MOV the render worker uploaded).
|
||||
*/
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ versionId: string }> }
|
||||
) {
|
||||
const session = await auth();
|
||||
if (!session?.user) {
|
||||
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||
}
|
||||
|
||||
const { versionId } = await params;
|
||||
const version = await db.version.findUnique({
|
||||
where: { id: versionId },
|
||||
select: { highResKey: true, highResFilename: true },
|
||||
});
|
||||
|
||||
if (!version?.highResKey) {
|
||||
return NextResponse.json({ error: "No high-res file available" }, { status: 404 });
|
||||
}
|
||||
|
||||
const url = await generateHetznerDownloadUrl(
|
||||
version.highResKey,
|
||||
version.highResFilename ?? "high-res.mov"
|
||||
);
|
||||
return NextResponse.json({ url });
|
||||
}
|
||||
@@ -60,6 +60,10 @@ interface Version {
|
||||
fps: number;
|
||||
duration: number | null;
|
||||
frameCount?: number | null;
|
||||
/** High quality review MP4 — the player's quality switch. */
|
||||
hqFileUrl?: string | null;
|
||||
/** Where the High Res download comes from: this version's ProRes, or the shot's legacy file. */
|
||||
highResSource?: "version" | "shot" | null;
|
||||
handleHead?: number | null;
|
||||
handleTail?: number | null;
|
||||
pictureStartFrame?: number | null;
|
||||
@@ -281,10 +285,17 @@ export default function ClientReviewPage({
|
||||
|
||||
const handleDownloadHighRes = async () => {
|
||||
const shotId = version?.highResShotId ?? version?.shot?.id;
|
||||
if (!shotId || !token) return;
|
||||
if (!version || !token) return;
|
||||
const endpoint =
|
||||
version.highResSource === "version"
|
||||
? `/api/client/${token}/versions/${version.id}/highres/download`
|
||||
: shotId
|
||||
? `/api/client/${token}/shots/${shotId}/highres/download`
|
||||
: null;
|
||||
if (!endpoint) return;
|
||||
setDownloadingHighRes(true);
|
||||
try {
|
||||
const res = await fetch(`/api/client/${token}/shots/${shotId}/highres/download`);
|
||||
const res = await fetch(endpoint);
|
||||
if (!res.ok) throw new Error("Could not get download link");
|
||||
const { url } = await res.json();
|
||||
// Open the presigned URL — the Content-Disposition header forces a download
|
||||
@@ -519,6 +530,7 @@ export default function ClientReviewPage({
|
||||
versionId={version.id}
|
||||
onAddComment={handlePlayerAddComment}
|
||||
handles={version}
|
||||
hqVideoUrl={version.hqFileUrl}
|
||||
// The director watches the cut as cut; handles are still one
|
||||
// toggle away, and flagged whenever the playhead is in one.
|
||||
defaultEditRangeOnly
|
||||
|
||||
@@ -41,6 +41,7 @@ import {
|
||||
Film,
|
||||
ShieldCheck,
|
||||
MessageSquare,
|
||||
Download,
|
||||
} from "lucide-react";
|
||||
|
||||
interface ReviewPageClientProps {
|
||||
@@ -54,6 +55,10 @@ interface ReviewPageClientProps {
|
||||
handleHead: number | null;
|
||||
handleTail: number | null;
|
||||
pictureStartFrame: number | null;
|
||||
hqFileUrl: string | null;
|
||||
highResKey: string | null;
|
||||
highResFilename: string | null;
|
||||
highResSize: bigint | number | null;
|
||||
approvalStatus: string;
|
||||
notes: string | null;
|
||||
isClientVisible: boolean;
|
||||
@@ -103,6 +108,11 @@ interface ReviewPageClientProps {
|
||||
userRole?: string;
|
||||
}
|
||||
|
||||
function formatBytes(bytes: number): string {
|
||||
if (bytes >= 1e9) return `${(bytes / 1e9).toFixed(1)} GB`;
|
||||
return `${Math.max(1, Math.round(bytes / 1e6))} MB`;
|
||||
}
|
||||
|
||||
const APPROVAL_STATUS_STYLES: Record<string, string> = {
|
||||
PENDING_REVIEW: "bg-amber-500/10 text-amber-400 border-amber-500/20",
|
||||
APPROVED: "bg-emerald-500/10 text-emerald-400 border-emerald-500/20",
|
||||
@@ -131,6 +141,7 @@ export function ReviewPageClient({
|
||||
const [isInternallyApproving, setIsInternallyApproving] = useState(false);
|
||||
const [showVersions, setShowVersions] = useState(false);
|
||||
const [commentsOpen, setCommentsOpen] = useState(true);
|
||||
const [downloadingProRes, setDownloadingProRes] = useState(false);
|
||||
|
||||
const playerRef = useRef<ReviewPlayerRef>(null);
|
||||
|
||||
@@ -141,6 +152,20 @@ export function ReviewPageClient({
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
|
||||
const handleDownloadProRes = async () => {
|
||||
setDownloadingProRes(true);
|
||||
try {
|
||||
const res = await fetch(`/api/versions/${version.id}/highres/download`);
|
||||
if (!res.ok) throw new Error("Could not get download link");
|
||||
const { url } = await res.json();
|
||||
window.open(url, "_blank", "noopener,noreferrer");
|
||||
} catch {
|
||||
toast({ title: "Download failed", variant: "destructive" });
|
||||
} finally {
|
||||
setDownloadingProRes(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAddComment = useCallback(() => {
|
||||
// Pause player first
|
||||
playerRef.current?.pause();
|
||||
@@ -253,7 +278,7 @@ export function ReviewPageClient({
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Link>
|
||||
|
||||
<div className="flex items-center gap-2 flex-1 min-w-0">
|
||||
<div className="flex items-center gap-2 flex-1 min-w-0 overflow-hidden">
|
||||
<span className="text-xs text-muted-foreground hidden sm:block">
|
||||
{project?.code}
|
||||
</span>
|
||||
@@ -287,6 +312,24 @@ export function ReviewPageClient({
|
||||
</DropdownMenu>
|
||||
</div>
|
||||
|
||||
{/* ProRes — this version's delivery MOV, uploaded by the render worker */}
|
||||
{version.highResKey && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
className="h-7 shrink-0 gap-1 text-xs text-sky-400"
|
||||
disabled={downloadingProRes}
|
||||
onClick={handleDownloadProRes}
|
||||
title={
|
||||
(version.highResFilename ?? "ProRes") +
|
||||
(version.highResSize ? ` · ${formatBytes(Number(version.highResSize))}` : "")
|
||||
}
|
||||
>
|
||||
<Download className="h-3 w-3" />
|
||||
<span className="hidden lg:inline">{downloadingProRes ? "Getting link…" : "ProRes"}</span>
|
||||
</Button>
|
||||
)}
|
||||
|
||||
{/* Handles — outside the breadcrumb so it never gets squeezed */}
|
||||
{userRole !== "CLIENT" && (
|
||||
<div className="shrink-0">
|
||||
@@ -380,6 +423,7 @@ export function ReviewPageClient({
|
||||
onAddComment={handleAddComment}
|
||||
onAnnotationSaved={handleAnnotationSaved}
|
||||
handles={version}
|
||||
hqVideoUrl={version.hqFileUrl}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user