MCPcopy Index your code
hub / github.com/simstudioai/sim / getVideoDimensions

Function getVideoDimensions

apps/sim/app/api/tools/video/route.ts:1353–1375  ·  view source on GitHub ↗
(
  aspectRatio: string,
  resolution: string
)

Source from the content-addressed store, hash-verified

1351}
1352
1353function 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}

Callers 4

generateWithRunwayFunction · 0.85
generateWithVeoFunction · 0.85
generateWithLumaFunction · 0.85
generateWithFalAIFunction · 0.85

Calls 1

replaceMethod · 0.65

Tested by

no test coverage detected