This commit is contained in:
949036910@qq.com
2026-06-01 22:08:18 +08:00
parent 474f6823fe
commit 4dada0c1a0
2 changed files with 163 additions and 34 deletions

View File

@@ -278,11 +278,12 @@ function buildDrawtextForMatch(match, layout) {
const t0 = match.startSec.toFixed(3);
const t1 = match.endSec.toFixed(3);
const enable = `between(t\\,${t0}\\,${t1})`;
/** 用 gte*lte 避免 between(t,a,b) 中逗号打断 -vf 滤镜链 */
const enable = `gte(t\\,${t0})*lte(t\\,${t1})`;
let fontsizePart = String(baseSize);
if (match.effectType === "pulse-scale") {
fontsizePart = `${baseSize}*(1+0.1*sin(2*PI*(t-${t0})*4))`;
fontsizePart = `${baseSize}*(1+0.08*sin(8*PI*t))`;
}
const parts = [
@@ -323,7 +324,19 @@ function buildKeywordDrawtextFilter(matches, opts) {
position: String(style.position || "bottom"),
};
return matches.map((m) => buildDrawtextForMatch(m, layout)).join(",");
const filters = matches.map((m) => buildDrawtextForMatch(m, layout));
const chain = filters.join(",");
if (chain.length > 6000) {
logKeywordWarn("drawtext 滤镜过长,仅保留前 40 个关键词");
return filters.slice(0, 40).join(",");
}
return chain;
}
function logKeywordWarn(msg, fields) {
if (globalThis.__native?.log) {
globalThis.__native.log("warn", `[autoGenerateSubtitleAndBGM] ${msg}`, fields ?? null);
}
}
/**