Open zjqiudan opened 2 years ago
Oh sorry, I've been busy lately. question check later
@zjqiudan
这个文件下
https://github.com/tnfe/FFCreator/blob/master/lib/node/subtitle.js
原代码 ` punctuation() { const fps = this.rootConf('fps'); const duration = this.conf.duration; const totalLength = this.conf.text.length; const list = this.text.split(SIGN).filter(elem => elem); let start = 0; this.totalFrames = duration * fps + this.frameBuffer;
forEach(list, text => {
// text += sign;
const time = (text.length / totalLength) * duration;
const frames = start + time * fps;
this.textList.push({ start, frames, text, draw: false });
start = frames;
});
} `
修改之后的代码
` punctuation() { const fps = this.rootConf('fps'); const duration = this.conf.duration; const totalLength = this.conf.text.length; const list = this.text.split(SIGN).filter(elem => elem); let start = 0; this.totalFrames = duration * fps + this.frameBuffer;
forEach(list, text => {
// text += sign;
const time = ((text.length+1) / totalLength) * duration;
const frames = start + time * fps;
this.textList.push({ start, frames, text, draw: false });
start = frames;
});
}`
主要是修改了这里
const time = ((text.length+1) / totalLength) * duration;
我看了一下源码,标点符号应该也有一个长度的,这里添加了一下,大概能同步吧,相差几十毫秒。 出现以下情况也会音画不同步。
Great, please submit a pr.
开始以为是标点符号的问题,但是去掉标点符号也还是无法精确同步(比如一段60秒的视频,在第20秒的时候就会突然出现,这句话字幕没有念完,字幕就跳到下一句话了),请问有什么办法可以解决,谢谢!