20 lines
995 B
TypeScript
20 lines
995 B
TypeScript
export const VIDEO_DURATION_OPTIONS = [6, 9, 10, 15] as const;
|
|
export const VIDEO_RESOLUTION_OPTIONS = [480, 720, 1080, 1440, 2160] as const;
|
|
export const VIDEO_RESOLUTION_CAPABILITY_OPTIONS = VIDEO_RESOLUTION_OPTIONS.map((value) => `${value}p`);
|
|
export const VIDEO_DURATION_MIN = 1;
|
|
|
|
export function normalizeVideoDuration(value: string | number | undefined) {
|
|
const seconds = Math.floor(Number(value) || VIDEO_DURATION_OPTIONS[0]);
|
|
return String(Math.max(VIDEO_DURATION_MIN, seconds));
|
|
}
|
|
|
|
export function normalizeVideoResolution(value: string | number | undefined) {
|
|
const token = String(value || "").trim().toLowerCase();
|
|
if (token === "low") return "480";
|
|
if (token === "auto" || token === "medium" || token === "high") return "720";
|
|
if (token === "2k") return "1440";
|
|
if (token === "4k") return "2160";
|
|
const resolution = Number(token.replace(/p$/i, ""));
|
|
return Number.isFinite(resolution) && resolution > 0 ? String(Math.floor(resolution)) : "720";
|
|
}
|