ditto/packages/transcode/analyze.ts
2025-02-28 18:29:41 -06:00

15 lines
424 B
TypeScript

import { ffprobe } from './ffprobe.ts';
export async function getVideoDimensions(
input: URL | ReadableStream<Uint8Array>,
): Promise<{ width: number; height: number } | null> {
const stream = ffprobe(input, {
'v': 'error',
'select_streams': 'v:0',
'show_entries': 'stream=width,height',
'of': 'json',
});
const { streams: [result] } = await new Response(stream).json();
return result ?? null;
}