ai-tube-clap-exporter / src /core /ffmpeg /addTextToVideo.mts
jbilcke-hf's picture
jbilcke-hf HF staff
another step for the Stories Factory (mp4 generation)
46fcec6
raw
history blame
920 Bytes
import { createTextOverlayImage } from "./createTextOverlayImage.mts"
import { addImageToVideo } from "./addImageToVideo.mts"
import { deleteFile } from "../files/deleteFile.mts"
export async function addTextToVideo({
inputVideoPath,
outputVideoPath,
text,
width,
height,
}: {
inputVideoPath: string
outputVideoPath: string
text: string
width: number
height: number
}): Promise<string> {
const { filePath: temporaryImageOverlayFilePath } = await createTextOverlayImage({
text,
width,
height,
})
console.log("addTextToVideo: temporaryImageOverlayFilePath:", temporaryImageOverlayFilePath)
const pathToVideo = await addImageToVideo({
inputVideoPath,
inputImagePath: temporaryImageOverlayFilePath,
outputVideoPath,
})
await deleteFile(temporaryImageOverlayFilePath)
console.log("addTextToVideo: outputVideoPath:", outputVideoPath)
return outputVideoPath
}