feat(playlist): seamless playback of selected shots, cut only
Deploy / deploy (push) Successful in 3m12s
Deploy / deploy (push) Successful in 3m12s
Check shots on the Playlist page and "Play selection" plays them back to back without slate or handles. The cut comes from the version's handle and slate metadata (new cutSpan in lib/handles); the media is never changed. SequencePlayer double-buffers two videos: the next clip is parked a few frames before its cut-in and pre-rolled hidden, the outgoing clip pauses on its last cut frame, and the cut fires on the incoming clip's cut-in frame (requestVideoFrameCallback), with the start time calibrated at each cut. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+41
-3
@@ -61,6 +61,21 @@ export function computeEditRange(
|
||||
const tail = Math.max(0, Math.floor(handles.handleTail ?? 0));
|
||||
if (head === 0 && tail === 0) return null;
|
||||
|
||||
const { pictureStart, pictureEnd } = pictureBounds(handles, totalFrames);
|
||||
const cutIn = Math.min(pictureStart + head, pictureEnd);
|
||||
const tailStart = Math.max(cutIn, pictureEnd - tail);
|
||||
|
||||
return { pictureStart, cutIn, tailStart, pictureEnd };
|
||||
}
|
||||
|
||||
/**
|
||||
* Where the picture sits in the media: after any slate, up to the end of the
|
||||
* rendered frames. See computeEditRange for how the slate is found.
|
||||
*/
|
||||
function pictureBounds(
|
||||
handles: VersionHandles,
|
||||
totalFrames: number
|
||||
): { pictureStart: number; pictureEnd: number } {
|
||||
const frameCount =
|
||||
handles.frameCount != null && handles.frameCount > 0 ? Math.floor(handles.frameCount) : null;
|
||||
|
||||
@@ -80,10 +95,33 @@ export function computeEditRange(
|
||||
const pictureEnd =
|
||||
frameCount != null ? Math.min(totalFrames, pictureStart + frameCount) : totalFrames;
|
||||
|
||||
const cutIn = Math.min(pictureStart + head, pictureEnd);
|
||||
const tailStart = Math.max(cutIn, pictureEnd - tail);
|
||||
return { pictureStart, pictureEnd };
|
||||
}
|
||||
|
||||
return { pictureStart, cutIn, tailStart, pictureEnd };
|
||||
/** A half-open frame range [start, end) of the review media. */
|
||||
export interface FrameSpan {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The frames a seamless playlist plays for this version: the cut when handles
|
||||
* are marked, otherwise the whole picture — never the slate. Falls back to
|
||||
* the whole media rather than an empty span, so a clip never plays nothing.
|
||||
*/
|
||||
export function cutSpan(
|
||||
handles: VersionHandles | null | undefined,
|
||||
totalFrames: number
|
||||
): FrameSpan | null {
|
||||
if (!(totalFrames > 0)) return null;
|
||||
const edit = computeEditRange(handles, totalFrames);
|
||||
const span = edit
|
||||
? { start: edit.cutIn, end: edit.tailStart }
|
||||
: (() => {
|
||||
const { pictureStart, pictureEnd } = pictureBounds(handles ?? {}, totalFrames);
|
||||
return { start: pictureStart, end: pictureEnd };
|
||||
})();
|
||||
return span.end > span.start ? span : { start: 0, end: totalFrames };
|
||||
}
|
||||
|
||||
export type FrameRegion = "slate" | "head" | "edit" | "tail";
|
||||
|
||||
Reference in New Issue
Block a user