9660cdc21c
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>
107 lines
3.2 KiB
TypeScript
107 lines
3.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { auth } from "@/auth";
|
|
import { db } from "@/lib/db";
|
|
import { shotThumbnail } from "@/lib/shot-thumbnail";
|
|
|
|
export async function GET(req: NextRequest) {
|
|
const session = await auth();
|
|
if (!session?.user) {
|
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
|
}
|
|
|
|
const projectId = req.nextUrl.searchParams.get("projectId");
|
|
if (!projectId) {
|
|
return NextResponse.json({ error: "projectId required" }, { status: 400 });
|
|
}
|
|
|
|
// All versions are linked to tasks (taskId), not directly to shots.
|
|
// We query shots with their tasks, and for each task get the latest version.
|
|
const shots = await db.shot.findMany({
|
|
where: {
|
|
projectId,
|
|
tasks: {
|
|
some: {
|
|
versions: { some: { isLatest: true } },
|
|
},
|
|
},
|
|
},
|
|
orderBy: [{ episode: "asc" }, { scene: "asc" }, { shotNumber: "asc" }],
|
|
select: {
|
|
id: true,
|
|
shotCode: true,
|
|
episode: true,
|
|
status: true,
|
|
shotApprovalStatus: true,
|
|
sharedWithClient: true,
|
|
thumbnailUrl: true,
|
|
generatedThumbnailUrl: true,
|
|
tasks: {
|
|
select: {
|
|
id: true,
|
|
title: true,
|
|
versions: {
|
|
where: { isLatest: true },
|
|
take: 1,
|
|
orderBy: { createdAt: "desc" },
|
|
select: {
|
|
id: true,
|
|
versionNumber: true,
|
|
fileUrl: true,
|
|
thumbnailUrl: true,
|
|
posterUrl: true,
|
|
fps: true,
|
|
frameCount: true,
|
|
hqFileUrl: true,
|
|
handleHead: true,
|
|
handleTail: true,
|
|
pictureStartFrame: true,
|
|
approvalStatus: true,
|
|
mimeType: true,
|
|
createdAt: true,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
// For each shot, pick the most recently uploaded latest version across all tasks
|
|
const playlist = shots
|
|
.map((shot) => {
|
|
const versions = shot.tasks
|
|
.flatMap((t) => t.versions.map((v) => ({ ...v, taskTitle: t.title })))
|
|
.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
|
|
const latest = versions[0] ?? null;
|
|
if (!latest) return null;
|
|
|
|
return {
|
|
id: shot.id,
|
|
shotCode: shot.shotCode,
|
|
episode: shot.episode,
|
|
status: shot.status,
|
|
shotApprovalStatus: shot.shotApprovalStatus,
|
|
sharedWithClient: shot.sharedWithClient,
|
|
thumbnailUrl: shotThumbnail(shot),
|
|
latestVersion: {
|
|
id: latest.id,
|
|
versionNumber: latest.versionNumber,
|
|
fileUrl: latest.fileUrl,
|
|
thumbnailUrl: latest.thumbnailUrl,
|
|
posterUrl: latest.posterUrl,
|
|
fps: latest.fps,
|
|
frameCount: latest.frameCount,
|
|
hqFileUrl: latest.hqFileUrl,
|
|
handleHead: latest.handleHead,
|
|
handleTail: latest.handleTail,
|
|
pictureStartFrame: latest.pictureStartFrame,
|
|
approvalStatus: latest.approvalStatus,
|
|
taskTitle: latest.taskTitle,
|
|
},
|
|
};
|
|
})
|
|
.filter((s): s is NonNullable<typeof s> => s !== null);
|
|
|
|
return NextResponse.json({ shots: playlist });
|
|
}
|