Open yangshen2000 opened 1 year ago
const { FFScene, FFText, FFVideo, FFAlbum, FFImage, FFCreator, FFVideoAlbum, FFChart } = require("ffcreator"); const path = require("path"); const outputDir = path.join(__dirname, "./output"); const cacheDir = path.join(__dirname, "./cache"); // 创建FFCreator 实例 const creator = new FFCreator({ cacheDir, outputDir, width: 600, height: 600, transparent: true, voImageExtra: 'png', cacheFormat: 'png', ext: 'mov', defaultOutputOptions: { merge: false, options: ['-vcodec', 'png', '-c:v', 'libx264'] }, }); // 创建场景 const scene = new FFScene(); scene.setDuration(3); scene.setBgColor('transparent') creator.addChild(scene); option = { xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [ { data: [150, 230, 224, 218, 135, 147, 260], type: 'line' } ] }; const fchart = new FFChart({ // theme: 'light', option: option, x: 100, y: 100, width: 400, height: 400, }); scene.addChild(fchart); creator.start(); // 开始加工 creator.output(path.join(__dirname, "./output/chart.mov")); // 开始加工 creator.on('complete', e => { console.log(`FFCreator completed`) });
https://github.com/tnfe/FFCreator/pull/334