I am adding 2 lines of watermarks but only first is visible
ffmpeg()
.input(tempLocalPath)
.complexFilter([
`[0:v]drawtext=text='${watermarkTextLine1}':x=(w-tw)/2:y=(h-460):fontsize=24:fontcolor=white@0.5:fontfile=/Windows/Fonts/arial.ttf`,
`[0:v]drawtext=text='${watermarkTextLine2}':x=(w-tw)/2:y=(h-200):fontsize=32:fontcolor=red:fontfile=/Windows/Fonts/arial.ttf`,
])
.output(
path.join(tempLocalDir, video_cid.replace(".mp4", "-") + "watermarked.mp4"),
)
.on("end", function () {
// Send the watermarked video as a response
res.download(
path.join(
tempLocalDir,
video_cid.replace(".mp4", "-") + "watermarked.mp4",
),
"video.mp4",
function (downloadError) {
if (downloadError) {
console.error("Error during download:", downloadError);
}
// Clean up: Delete the temporary local file
fs.unlink(tempLocalPath, (unlinkError) => {
if (unlinkError) {
console.error(
"Error deleting the temporary video file:",
unlinkError,
);
}
});
},
);
})
.inputFormat("mp4")
.run();
.complexFilter([
`[0:v]drawtext=text='${watermarkTextLine1}':x=(w-tw)/2:y=(h-460):fontsize=24:fontcolor=white@0.5:fontfile=/Windows/Fonts/arial.ttf[filter_1]`,
`[filter_1]drawtext=text='${watermarkTextLine2}':x=(w-tw)/2:y=(h-200):fontsize=32:fontcolor=red:fontfile=/Windows/Fonts/arial.ttf`,
])
Because two filters had same input [0:v]
, and same output (but ffmpeg select one).
We need to use the output of the first filter for the input of the next filter.