I am creating a server-side video renderer in node.js. I need to add images on an existing video file every frame. I need to set the specific position of each frame in the rendered video. I am holding all the frames of the images in Readable
. This is my code that works, but does not take into account the position of the images. How can I modify it? Of course I have a list with images coordinates - but I don't know how to make a filter out of this.
this.stream
is a list of images.
const filter = ["[1:v]format=argb,setpts=PTS+" + 0 + "/TB[out]",
{
filter: "overlay",
options: {
enable: "between(t," + 0 + "," + 9 + ")",
x: "0",
y: "0",
},
inputs: "[0:v][out]",
outputs: "tmp",
}
]
const Options = [
"-crf 16",
"-f mp4",
"-vcodec libx264",
"-movflags frag_keyframe+empty_moov",
"-pix_fmt yuv420p",
];
var ffmpeg = require('fluent-ffmpeg');
ffmpeg.setFfmpegPath(ffm.path);
var command = ffmpeg();
const outputStream = fs.createWriteStream(this.Path + "test.mp4");
command.input(this.Path + "input.mp4");
command.input(this.stream).inputFPS(23);
command.outputOptions(Options);
command.fps(23);
command.complexFilter(filter, "tmp");
command.output(outputStream);