部分tts配音和背景音乐融合后声音会忽大忽小
zjqiudan opened this issue · comments
附件是背景音乐和问题字幕配音
Desktop.zip
经过四次测试
1)附件的背景音乐+配音,生成后的视频在第17秒时声音变小
2)如果换掉背景音乐 不换配音,问题存在
3)如果换掉背景音乐 换掉配音,问题不存在
4)如果不换背景音乐 换掉配音,问题不存在
请问这种情况如何处理
`const path = require('path');
const colors = require('colors');
const startAndListen = require('./listen');
const {
FFCreatorCenter,
FFScene,
FFAlbum,
FFSubtitle,
FFText,
FFImage,
FFCreator,
} = require('../');
const createFFTask = () => {
const bg = path.join(__dirname, './assets/imgs/bg/04.jpeg');
const img1 = path.join(__dirname, './assets/imgs/album/06.jpeg');
const img2 = path.join(__dirname, './assets/imgs/album/05.jpeg');
const img3 = path.join(__dirname, './assets/imgs/album/04.jpeg');
const img4 = path.join(__dirname, './assets/imgs/album/03.jpeg');
const img5 = path.join(__dirname, './assets/imgs/album/02.jpeg');
const logo = path.join(__dirname, './assets/imgs/logo/logo2.png');
const font1 = path.join(__dirname, './assets/font/font1.ttf');
// const tts = path.join(__dirname, './assets/audio/tts.wav');
const tts = path.join(__dirname, './assets/291ae4e6782fc11f84b59d83017df9be.wav');
const outputDir = path.join(__dirname, './output/');
const cacheDir = path.join(__dirname, './cache/');
const audio = path.join(__dirname, './assets/Getaway.mp3');
// create creator instance
const width = 576;
const height = 1024;
const creator = new FFCreator({
cacheDir,
outputDir,
width,
height,
debug: false,
});
creator.addAudio({ path: audio, loop: true });
// create FFScene
const scene1 = new FFScene();
const scene2 = new FFScene();
scene1.setBgColor('#fc427b');
scene2.setBgColor('#019333');
// add image album
const album = new FFAlbum({
list: [img1, img2, img3, img4, img5],
x: width / 2,
y: height / 2,
width: width,
height: 384,
showCover: true, // 默认显示封面
});
album.setTransition('fadeInLeft');
album.setDuration(2.5);
scene1.addChild(album);
// add title text
const text = new FFText({ text: 'FFCreator字幕DEMO', x: width / 2, y: 150, fontSize: 40 });
text.setColor('#ffffff');
text.setBackgroundColor('#019333');
text.addEffect('fadeInUp', 1, 1);
text.alignCenter();
text.setStyle({ padding: 10 });
scene1.addChild(text);
// add logo
const flogo2 = new FFImage({ path: logo, x: width / 2, y: 60 });
flogo2.setScale(0.6);
scene1.addChild(flogo2);
// add audio to scene1
scene1.addAudio(tts);
// subtitle
const title =
// '跟计算机工作酷就酷在这里它们不会生气能记住所有东西还有它们不会喝光你的啤酒。计算机就跟比基尼一样省去了人们许多的胡思乱想。';
'如果你从未,体验过优质工装,你会怎么样,优质工装,工作更舒适,耐磨面料,持久耐用,多口袋设计,实用方便,透气性好,夏天不闷,冬季保暖,四季适用,款式多样,满足不同需求,批发价格,经济实惠,团队定制,logo随心印,';
const subtitle = new FFSubtitle({
comma: true, // 是否逗号分割
backgroundColor: '#00219C',
color: '#fff',
fontSize: 24,
x: width / 2,
y: height / 2 + 300,
});
const _width = 100
const _style = {
wordWrap: true,
wordWrapWidth: _width,
breakWords: true,
align: 'center',
};
// subtitle.setStyle(_style);
subtitle.setText(title);
subtitle.setFont(font1);
subtitle.setSpeech(tts); // 语音配音-tts
subtitle.frameBuffer = 24;
// subtitle.setDuration(album.getTotalDuration() + 1); 没有tts配音时候可以手动设置
scene1.addChild(subtitle);
scene1.setDuration(22);
scene1.setTransition('FastSwitch', 1.5);
creator.addChild(scene1);
// add scene2 background
const fbg = new FFImage({ path: bg });
fbg.setXY(width / 2, height / 2);
scene2.addChild(fbg);
// logo
const flogo = new FFImage({ path: logo, x: width / 2, y: height / 2 - 150 });
flogo.addEffect('fadeInDown', 1, 1.2);
scene2.addChild(flogo);
scene2.setDuration(4);
creator.addChild(scene2);
creator.start();
creator.closeLog();
creator.on('start', () => {
console.log(FFCreator start
);
});
creator.on('error', e => {
console.log(FFCreator error: ${JSON.stringify(e)}
);
});
creator.on('progress', e => {
console.log(colors.yellow(FFCreator progress: ${(e.percent * 100) >> 0}%
));
});
creator.on('complete', e => {
console.log(
colors.magenta(FFCreator completed: \n USEAGE: ${e.useage} \n PATH: ${e.output}
),
);
console.log(colors.green(`\n --- You can press the s key or the w key to restart! --- \n`));
});
return creator;
};
module.exports = () => startAndListen(() => FFCreatorCenter.addTask(createFFTask));
`
mark