tnfe / FFCreator

A fast video processing library based on node.js (一个基于node.js的高速视频制作库)
http://tnfe.github.io/FFCreator/
MIT License
2.78k stars 392 forks source link

FFchart生成的图表背景是黑色的, 代码如下,请问怎么弄成透明背景 #403

Open yangshen2000 opened 9 months ago

yangshen2000 commented 9 months 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`)
});
drawcall commented 8 months ago

https://github.com/tnfe/FFCreator/pull/334