( dir: string, inputPath: string, input: MediaFile, _options: FfmpegOptions )
| 512 | } |
| 513 | |
| 514 | async function fade( |
| 515 | dir: string, |
| 516 | inputPath: string, |
| 517 | input: MediaFile, |
| 518 | _options: FfmpegOptions |
| 519 | ): Promise<FfmpegResult> { |
| 520 | const probe = await probeFile(inputPath) |
| 521 | const duration = probe.durationSeconds || 0 |
| 522 | const fadeDur = Math.min(0.5, duration / 4 || 0.5) |
| 523 | const outStart = Math.max(0, duration - fadeDur) |
| 524 | const isVideo = input.mimeType.startsWith('video/') || probe.hasVideo |
| 525 | const ext = isVideo ? 'mp4' : extFromMime(input.mimeType) |
| 526 | const outputPath = path.join(dir, `out.${ext}`) |
| 527 | const command = ffmpeg(inputPath) |
| 528 | if (isVideo) { |
| 529 | command.videoFilters([`fade=t=in:st=0:d=${fadeDur}`, `fade=t=out:st=${outStart}:d=${fadeDur}`]) |
| 530 | } |
| 531 | command.audioFilters([`afade=t=in:st=0:d=${fadeDur}`, `afade=t=out:st=${outStart}:d=${fadeDur}`]) |
| 532 | await runCommand(command, outputPath) |
| 533 | return readOut(outputPath, ext) |
| 534 | } |
| 535 | |
| 536 | async function extractAudio( |
| 537 | dir: string, |
no test coverage detected