From ad9cc676e65ea3a0356ddeca1bf9d633b4ab35cc Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 28 Feb 2025 18:41:13 -0600 Subject: [PATCH] Improve getVideoDimensions --- packages/transcode/analyze.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/transcode/analyze.ts b/packages/transcode/analyze.ts index fe84a0c0..4221c280 100644 --- a/packages/transcode/analyze.ts +++ b/packages/transcode/analyze.ts @@ -6,10 +6,18 @@ export async function getVideoDimensions( const stream = ffprobe(input, { 'v': 'error', 'select_streams': 'v:0', - 'show_entries': 'stream=width,height', + 'show_streams': '', 'of': 'json', }); - const { streams: [result] } = await new Response(stream).json(); - return result ?? null; + const { streams } = await new Response(stream).json(); + + for (const stream of streams) { + if (stream.codec_type === 'video') { + const { width, height } = stream; + return { width, height }; + } + } + + return null; }