I want to make the code run only after ffmpeg has finished rendering the videos. Currently, the code runs faster than the videos can render.
videos.forEach((vid, i) => {
ffmpeg(`${process.cwd()}/video/tmp/${vid}`)
.outputOptions(['-r 30', '-filter:v scale=w=720:h=1280', '-crf 20'])
.save(`${process.cwd()}/video/tmp/${vid}`)
.on('end', ()=> console.log(`Video ${i} rendered`));
});
console.log("Fully Completed");
The console shows:
Fully Completed
Video 0 rendered
Video 1 rendered
The execution should be opposite. How can I make the code wait for video to finish rendering before continuing?