mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
15 lines
424 B
TypeScript
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;
|
|
}
|