mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Improve getVideoDimensions
This commit is contained in:
parent
5f10f92d4e
commit
ad9cc676e6
1 changed files with 11 additions and 3 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue