( dir: string, inputPath: string, options: FfmpegOptions )
| 446 | } |
| 447 | |
| 448 | async 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 | |
| 472 | async function overlayImage( |
| 473 | dir: string, |
no test coverage detected