( aspectRatio: string, resolution: string )
| 1351 | } |
| 1352 | |
| 1353 | function getVideoDimensions( |
| 1354 | aspectRatio: string, |
| 1355 | resolution: string |
| 1356 | ): { width: number; height: number } { |
| 1357 | let height: number |
| 1358 | if (resolution === '4k' || resolution === '2160p') { |
| 1359 | height = 2160 |
| 1360 | } else if (resolution === 'true_1080p') { |
| 1361 | height = 1080 |
| 1362 | } else { |
| 1363 | const parsedHeight = Number.parseInt(resolution.replace('p', '')) |
| 1364 | height = Number.isFinite(parsedHeight) ? parsedHeight : 1080 |
| 1365 | } |
| 1366 | |
| 1367 | const [ratioW, ratioH] = aspectRatio.split(':').map(Number) |
| 1368 | if (!Number.isFinite(ratioW) || !Number.isFinite(ratioH) || ratioH === 0) { |
| 1369 | return { width: Math.round((height * 16) / 9), height } |
| 1370 | } |
| 1371 | |
| 1372 | const width = Math.round((height * ratioW) / ratioH) |
| 1373 | |
| 1374 | return { width, height } |
| 1375 | } |
no test coverage detected