MCPcopy
hub / github.com/simstudioai/sim / addText

Function addText

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

Source from the content-addressed store, hash-verified

487}
488
489async function addText(
490 dir: string,
491 inputPath: string,
492 options: FfmpegOptions
493): Promise<FfmpegResult> {
494 if (!options.text) throw new Error('add_text requires text')
495 const pos = TEXT_POSITION[options.position || 'bottom'] || TEXT_POSITION.bottom
496 const drawtext = [
497 `text='${escapeDrawtext(options.text)}'`,
498 'fontcolor=white',
499 'fontsize=h/18',
500 'box=1',
501 'boxcolor=black@0.5',
502 'boxborderw=20',
503 `x=${pos.x}`,
504 `y=${pos.y}`,
505 ].join(':')
506 const outputPath = path.join(dir, 'out.mp4')
507 const command = ffmpeg(inputPath)
508 .videoFilters(`drawtext=${drawtext}`)
509 .outputOptions(['-c:a', 'copy'])
510 await runCommand(command, outputPath)
511 return readOut(outputPath, 'mp4')
512}
513
514async function fade(
515 dir: string,

Callers 1

runFfmpegOperationFunction · 0.85

Calls 4

escapeDrawtextFunction · 0.85
readOutFunction · 0.85
joinMethod · 0.80
runCommandFunction · 0.70

Tested by

no test coverage detected