feat(review): High quality playback switch and per-version ProRes download
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:
twotalesanimation
2026-09-22 16:32:18 +02:00
parent bae46c2968
commit 9660cdc21c
27 changed files with 793 additions and 18 deletions
+33
View File
@@ -47,6 +47,9 @@ interface PlaybackControlsProps {
onTogglePlay: () => void;
onToggleFullscreen: () => void;
onAddComment: () => void;
/** Current quality, or null when the version has no High quality source. */
quality?: "standard" | "high" | null;
onQualityChange?: (quality: "standard" | "high") => void;
}
export function PlaybackControls({
@@ -59,6 +62,8 @@ export function PlaybackControls({
onTogglePlay,
onToggleFullscreen,
onAddComment,
quality = null,
onQualityChange,
}: PlaybackControlsProps) {
const {
isPlaying,
@@ -297,6 +302,34 @@ export function PlaybackControls({
)}
</div>
{/* Quality — only when the version has a High quality source */}
{quality && (
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="sm"
className={cn(
"h-7 px-1.5 font-mono text-[11px] font-bold tracking-wide",
quality === "high"
? "text-sky-400 bg-sky-400/10 hover:text-sky-300"
: "text-zinc-500 hover:text-white"
)}
onClick={() => onQualityChange?.(quality === "high" ? "standard" : "high")}
aria-pressed={quality === "high"}
aria-label="High quality"
>
HQ
</Button>
</TooltipTrigger>
<TooltipContent>
{quality === "high"
? "High quality — click for Standard (smaller, loads faster)"
: "Switch to High quality (full resolution, needs a fast connection)"}
</TooltipContent>
</Tooltip>
)}
{/* Edit range only — only for versions with handles marked */}
{editRange && (
<Tooltip>
+70 -1
View File
@@ -46,8 +46,13 @@ interface ReviewPlayerProps {
handles?: VersionHandles | null;
/** Start with playback kept to the edit (the client portal's default). */
defaultEditRangeOnly?: boolean;
/** High quality source (full res, high bitrate); enables the quality switch. */
hqVideoUrl?: string | null;
}
export type PlaybackQuality = "standard" | "high";
const QUALITY_KEY = "review:quality";
export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
function ReviewPlayer(
{
@@ -63,6 +68,7 @@ export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
addCommentFn,
handles,
defaultEditRangeOnly = false,
hqVideoUrl,
},
ref
) {
@@ -75,6 +81,41 @@ export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
const zoomLayerRef = useRef<HTMLDivElement>(null);
const reverseIntervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
const openedAtCut = useRef(false);
// ── Quality ──────────────────────────────────────────────────────────────
// Standard is the review MP4; High is the full-res, high-bitrate encode of
// the delivery MOV. The choice is a per-browser preference, read after
// mount so the server render and the first client render agree.
const [quality, setQuality] = useState<PlaybackQuality>("standard");
const [switchingQuality, setSwitchingQuality] = useState(false);
// Where to pick up once the other source has loaded.
const resumeRef = useRef<{ time: number; playing: boolean } | null>(null);
useEffect(() => {
try {
if (localStorage.getItem(QUALITY_KEY) === "high") setQuality("high");
} catch {
// storage blocked — Standard it is
}
}, []);
const activeSrc = quality === "high" && hqVideoUrl ? hqVideoUrl : videoUrl;
const changeQuality = useCallback(
(next: PlaybackQuality) => {
if (next === quality) return;
const video = videoRef.current;
if (video && video.readyState > 0 && hqVideoUrl) {
resumeRef.current = { time: video.currentTime, playing: !video.paused };
setSwitchingQuality(true);
}
setQuality(next);
try {
localStorage.setItem(QUALITY_KEY, next);
} catch {
// preference just isn't remembered
}
},
[quality, hqVideoUrl]
);
const [isReversing, setIsReversing] = useState(false);
const {
@@ -142,6 +183,8 @@ export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
setTotalFrames(0);
resetZoom();
openedAtCut.current = false;
resumeRef.current = null;
setSwitchingQuality(false);
}, [videoUrl, setCurrentFrame, setCurrentTime, setDuration, setTotalFrames, resetZoom]);
// ── Playback state sync ──────────────────────────────────────────────────
@@ -159,8 +202,24 @@ export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
const frames = durationToFrameCount(video.duration, fps);
setDuration(video.duration);
setTotalFrames(frames);
// A new source starts at 1x; keep the speed the reviewer chose.
video.playbackRate = useReviewStore.getState().playbackRate;
// Quality switch: carry on from the same frame, playing or not.
const resume = resumeRef.current;
resumeRef.current = null;
if (resume) {
video.currentTime = resume.time;
if (resume.playing) video.play().catch(() => {});
}
}, [fps, setDuration, setTotalFrames]);
// High quality failed to load (pruned, or a network hiccup): fall back to
// Standard rather than leave a black player. Not remembered as a choice.
const handleVideoError = useCallback(() => {
if (quality !== "high" || !hqVideoUrl) return;
setQuality("standard");
}, [quality, hqVideoUrl]);
/**
* Play — when keeping to the edit, from the cut in-point if the playhead
* is outside the cut (slate, a handle, or parked on the last cut frame).
@@ -413,12 +472,14 @@ export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
>
<video
ref={videoRef}
src={videoUrl}
src={activeSrc}
className="block w-full h-full object-contain"
onTimeUpdate={handleTimeUpdate}
onLoadedMetadata={handleLoadedMetadata}
onPlay={handlePlay}
onPause={handlePause}
onCanPlay={() => setSwitchingQuality(false)}
onError={handleVideoError}
preload="metadata"
playsInline
/>
@@ -485,6 +546,12 @@ export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
</div>
)}
{switchingQuality && (
<div className="pointer-events-none absolute bottom-3 left-3 rounded bg-black/70 px-2 py-1 text-xs text-white">
Loading {quality === "high" ? "high" : "standard"} quality…
</div>
)}
{/* JKL hint overlay — shown briefly when reversing */}
{isReversing && (
<div className="absolute top-3 left-3 rounded bg-black/60 px-2 py-1 text-xs font-mono text-white">
@@ -516,6 +583,8 @@ export const ReviewPlayer = forwardRef<ReviewPlayerRef, ReviewPlayerProps>(
onTogglePlay={togglePlayback}
onToggleFullscreen={toggleFullscreen}
onAddComment={handleAddComment}
quality={hqVideoUrl ? quality : null}
onQualityChange={changeQuality}
/>
</div>
);
+2 -2
View File
@@ -100,10 +100,10 @@ export function VersionHandlesButton({
size="sm"
className={cn("h-7 gap-1 text-xs", marked ? "text-amber-400" : "text-muted-foreground")}
onClick={openDialog}
title="Frames past the cut that aren't in the edit"
title={`${label} — frames past the cut that aren't in the edit`}
>
<Scissors className="h-3 w-3" />
<span className="hidden sm:inline">{label}</span>
<span className="hidden lg:inline">{label}</span>
</Button>
<Dialog open={open} onOpenChange={setOpen}>