Open-source AI podcast clipper. Generate vertical clips with face tracking and burned-in captions. CLI, MCP server, web app.
Python ai-toolsauto-captionscaptionscliffmpegmcpmcp-serveropusclip-alternativepodcast-clipspodcastsshortform-videovertical-videowhisper
export interface ByteRange {
start: number;
end: number;
}
/** Parse one RFC 9110 byte range, including suffix ranges used by browsers. */
export function resolveByteRange(header: string, fileSize: number): ByteRange | null {
if (!Number.isSafeInteger(fileSize) || fileSize <= 0) return null;
const match = /^bytes=(\d*)-(\d*)$/.exec(header.trim());
if (!match || (!match[1] && !match[2])) return null;
if (!match[1]) {
const suffixLength = Number.parseInt(match[2], 10);
if (!Number.isSafeInteger(suffixLength) || suffixLength <= 0) return null;
const length = Math.min(suffixLength, fileSize);
return { start: fileSize - length, end: fileSize - 1 };
}
const start = Number.parseInt(match[1], 10);
const requestedEnd = match[2] ? Number.parseInt(match[2], 10) : fileSize - 1;
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd)) return null;
if (start < 0 || start >= fileSize || requestedEnd < start) return null;
return { start, end: Math.min(requestedEnd, fileSize - 1) };
}