webstreamr/src/utils/size.ts
2025-08-28 19:01:14 +00:00

12 lines
410 B
TypeScript

import { Context } from '../types';
import { CustomRequestInit, Fetcher } from './Fetcher';
export const guessSizeFromMp4 = async (ctx: Context, fetcher: Fetcher, url: URL, init?: CustomRequestInit): Promise<number | undefined> => {
const mp4Head = await fetcher.head(ctx, url, init);
if (mp4Head['content-length']) {
return parseInt(mp4Head['content-length'] as string);
}
return undefined;
};