Improve getVideoDimensions

This commit is contained in:
Alex Gleason 2025-02-28 18:41:13 -06:00
parent 5f10f92d4e
commit ad9cc676e6
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -6,10 +6,18 @@ export async function getVideoDimensions(
const stream = ffprobe(input, { const stream = ffprobe(input, {
'v': 'error', 'v': 'error',
'select_streams': 'v:0', 'select_streams': 'v:0',
'show_entries': 'stream=width,height', 'show_streams': '',
'of': 'json', 'of': 'json',
}); });
const { streams: [result] } = await new Response(stream).json(); const { streams } = await new Response(stream).json();
return result ?? null;
for (const stream of streams) {
if (stream.codec_type === 'video') {
const { width, height } = stream;
return { width, height };
}
}
return null;
} }