mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-09-08 02:36:10 +00:00
* perf(studio): schedule adaptive timeline thumbnails * perf(studio): bound thumbnail decoding resources * perf(studio): virtualize timeline thumbnail media * perf(studio): prioritize timeline thumbnail work * perf(studio-server): coordinate cancelable thumbnail generation --------- Co-authored-by: Codex <codex@local>
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { buildProjectApiPath } from "./projectRouting";
|
|
|
|
export interface FrameCaptureRequest {
|
|
projectId: string;
|
|
compositionPath: string | null;
|
|
currentTime: number;
|
|
origin?: string;
|
|
}
|
|
|
|
function normalizeCompositionPath(compositionPath: string | null): string {
|
|
return compositionPath && compositionPath !== "master" ? compositionPath : "index.html";
|
|
}
|
|
|
|
export function buildFrameCaptureUrl({
|
|
projectId,
|
|
compositionPath,
|
|
currentTime,
|
|
origin = window.location.origin,
|
|
}: FrameCaptureRequest): string {
|
|
const compPath = normalizeCompositionPath(compositionPath);
|
|
const url = new URL(
|
|
buildProjectApiPath(projectId, `/thumbnail/${encodeURIComponent(compPath)}`),
|
|
origin,
|
|
);
|
|
url.searchParams.set("t", Math.max(0, currentTime).toFixed(3));
|
|
url.searchParams.set("format", "png");
|
|
url.searchParams.set("output", "source");
|
|
url.searchParams.set("v", String(Date.now()));
|
|
return url.toString();
|
|
}
|
|
|
|
export function buildFrameCaptureFilename(compositionPath: string | null, currentTime: number) {
|
|
const compPath = normalizeCompositionPath(compositionPath);
|
|
const base =
|
|
compPath
|
|
.split("/")
|
|
.pop()
|
|
?.replace(/\.html$/i, "") || "frame";
|
|
const frameTime = Math.max(0, currentTime).toFixed(3).replace(".", "-");
|
|
return `${base}-${frameTime}s.png`;
|
|
}
|