FFCreator
FFCreator copied to clipboard
简单测试案例运行后无响应,求解答
const path = require('path');
const colors = require('colors');
const { FFCreatorCenter, FFScene, FFImage, FFCreator } = require('ffcreator');
const img1 = path.join(__dirname , './data/img/01.jpg');
const img2 = path.join(__dirname , './data/img/02.jpg');
const img3 = path.join(__dirname , './data/img/03.jpg');
const tts1 = path.join(__dirname , './data/audio/1.wav');
const tts2 = path.join(__dirname , './data/audio/2.wav');
const tts3 = path.join(__dirname , './data/audio/3.wav');
const outputDir = path.join(__dirname, './output/');
const cacheDir = path.join(__dirname, './cache/');
// create creator instance
const width = 576;
const height = 1024;
const creator = new FFCreator({
cacheDir,
outputDir,
// cover,
width,
height,
//log: true,
highWaterMark: '3mb',
parallel: 8,
// audio,
// render:"blur",
});
// create FFScene
const scene1 = new FFScene();
const scene2 = new FFScene();
const scene3 = new FFScene();
let img1Obj = new FFImage({ path: img1, x: 0 , y:0});
// img1Obj.addEffect('fadeInDown', 1, 1.2);
img1Obj.setDuration(5);
scene1.addChild(img1Obj);
scene1.setTransition('TricolorCircle' , 1)
// scene1.setDuration(5)
let img2Obj = new FFImage({ path: img2, x: 0 , y:0});
// img2Obj.addEffect('fadeInDown', 1, 1.2);
img2Obj.setDuration(6);
scene2.addChild(img2Obj);
scene2.setTransition('HangAround' , 1)
// scene2.setDuration(5)
let img3Obj = new FFImage({ path: img3, x: 0 , y:0});
// img3Obj.addEffect('fadeInDown', 1, 1.2);
img3Obj.setDuration(4);
scene3.addChild(img3Obj);
scene3.setTransition('HangAround' , 1)
// scene3.setDuration(4)
creator.addChild(scene1)
creator.addChild(scene2)
creator.addChild(scene3)
//启动
creator.start();
creator.openLog();
creator.on('start', () => {
console.log(`FFCreator start`);
});
creator.on('error', e => {
console.log(colors.red(`FFCreator error: ${e.error}`));
});
creator.on('progress', e => {
console.log(colors.yellow(`FFCreator progress: ${(e.percent * 100) >> 0}%`));
});
creator.on('complete', e => {
console.log(e)
console.log(
colors.magenta(`FFCreator completed: \n USEAGE: ${e.useage} \n PATH: ${e.output} `),
);
});
以上代码通过 node test.js 运行后无结果响应,仅输出:
FFCreator start
如果将代码中的 第2、3场景注释掉,仅保留一个场景,就可以正常输出视频。
// creator.addChild(scene2)
// creator.addChild(scene3)
素材是没有问题的,但是不知道什么原因,很奇怪。 求解答,感谢!
运行环境: node v14.17.1 windows 10 专业版