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

Function scalePad

apps/sim/lib/media/ffmpeg.ts:448–470  ·  view source on GitHub ↗
(
  dir: string,
  inputPath: string,
  options: FfmpegOptions
)

Source from the content-addressed store, hash-verified

446}
447
448async function scalePad(
449 dir: string,
450 inputPath: string,
451 options: FfmpegOptions
452): Promise<FfmpegResult> {
453 let width = options.width
454 let height = options.height
455 if ((!width || !height) && options.aspectRatio && ASPECT_TARGETS[options.aspectRatio]) {
456 width = ASPECT_TARGETS[options.aspectRatio].w
457 height = ASPECT_TARGETS[options.aspectRatio].h
458 }
459 if (!width || !height) {
460 throw new Error('scale_pad requires width+height or a known aspectRatio (e.g. 9:16)')
461 }
462 const outputPath = path.join(dir, 'out.mp4')
463 const command = ffmpeg(inputPath)
464 .videoFilters(
465 `scale=${width}:${height}:force_original_aspect_ratio=decrease,pad=${width}:${height}:(ow-iw)/2:(oh-ih)/2,setsar=1`
466 )
467 .outputOptions(['-c:a', 'copy'])
468 await runCommand(command, outputPath)
469 return readOut(outputPath, 'mp4')
470}
471
472async function overlayImage(
473 dir: string,

Callers 1

runFfmpegOperationFunction · 0.85

Calls 3

readOutFunction · 0.85
joinMethod · 0.80
runCommandFunction · 0.70

Tested by

no test coverage detected