ai-tube-clap-exporter / src /core /ffmpeg /addTextToVideo.mts
jbilcke-hf's picture
jbilcke-hf HF staff
improve text overlay generation
deff001
raw
history blame
1.05 kB
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,
textStyle: "outline", // or "highlight"
fontSize: 4.5,
horizontalPosition: "center",
verticalPosition: "end",
px: 4,
py: 8,
width,
height,
})
// console.log("addTextToVideo: temporaryImageOverlayFilePath:", temporaryImageOverlayFilePath)
await addImageToVideo({
inputVideoPath,
inputImagePath: temporaryImageOverlayFilePath,
outputVideoPath,
})
await deleteFile(temporaryImageOverlayFilePath)
// console.log("addTextToVideo: outputVideoPath:", outputVideoPath)
return outputVideoPath
}