ff creator npm package
ff creator is a npm package for creating a short video. It is a very fast and useful npm package created by China. you can use instead of ffmpeg for creating short videos. This package also uses ffmpeg for creating videos. This package is very simple for creating short videos. It is very fast for rendering short videos.
How it works: full explanation.
creating creator
const creatorMain = new FFCreator({
cacheDir,
outputDir,
width: width,
height: height
});
creating scene
const slideScene = new FFScene();
slideScene.setBgColor(#ffffff);
slideScene.setDuration(2)
creating video
const video = new FFVideo({ path: mypath, width: videoWidth, height: videoHeight, x: videoX, y: videoY });
if (layer.mute === false) {
video.setAudio(true);
}
else {
video.setAudio(false);
}
video.addEffect({
type: 'fadeInDown',
time: 1,
delay: 1,
});
slideScene.addChild(video);
creating image
const img = new FFImage({ path: layer.src, width: imageWidth, height: imageHeight, x: imageX, y: imageY });
img.addEffect({
type: 'fadeInDown',
time: 1,
delay: 1,
});
slideScene.addChild(img);
creating text
const text = new FFImage({ path: myPath, width: width, height: height, x: width / 2, y: height / 2 }); text.addEffect({ type: 'fadeInDown', time: 1, delay: 1, }); slideScene.addChild(text);
const text = new FFImage({ path: myPath, width: width, height: height, x: width / 2, y: height / 2 });
text.addEffect({
type: 'fadeInDown',
time: 1,
delay: 1,
});
slideScene.addChild(text);
creating gif
const fgirl = new FFGifImage({ path: 'a.gif', x: 300 });
fgirl.addEffect('backInUp', 1.2, 1.5);
fgirl.setAnchor(0.5, 1);
scene1.addChild(fgirl);
add logo
// adding logo
let logo = JSON.parse(slideData.logo)
if (logo.enable === true && logo.src !== '') {
const logoWidth = 80 * multiplyNum;
const logoHeight = 80 * multiplyNum;
let logoXY = await getLogoXY(logo.pos, logoWidth, logoHeight)
const logoX = logoXY.x
const logoY = logoXY.y
const logoImg = new FFImage({ path: logo.src, width: logoWidth, height: logoHeight, x: logoX, y: logoY });
slideScene.addChild(logoImg);
}
after start rendering function explanation
creatorMain.output(outputDir + "_output.mp4");
creatorMain.start().then();
on start function
when rendering start this function call one time
creatorMain.on('start', () => {
// console.log(`FFCreator start`);
});
on error function
this function is call when has some error in rendering progress. this function will throw proper information about error.
creatorMain.on('error', async e => {
//enter your code
});
on progress function
this function call repeatedly till your video not rendered
creatorMain.on('progress', async e => {
console.log(`FFCreator progress: ${e.percent}`);
});
on complete function
this function call when your video is rendering is completed.
creatorMain.on('complete', e => {
//enter your code
});
code examples for creating video
if you have any doubts please let me know