fix: 字幕按实测发声段对齐 + 静音镜/包装踩坑 (v1.2.1)

- 纠正 render.md/pitfalls.md「按设计时间缩放字幕」错误做法,改为只认实测发声段
- 新增 scripts/align_subtitles.py(泛化对齐工具,配置外置、支持 dump-segs/init-config/dry-run)
- render_native.py 加 --ass 参数,读对齐 ASS 不被内置设计时间轴覆盖
- pitfalls/native-av/README/SKILL 补六条踩坑;install.sh 清单同步
This commit is contained in:
rong committed 2026-11-19 17:14:14 +08:00
1 parent d25c9304e1
commit a8e10b7b17
8 files changed
+396 -15

No files matched your search

+16 -1
View File
@@ -121,6 +121,9 @@ def main():
ap = argparse.ArgumentParser()
ap.add_argument("shots")
ap.add_argument("--mask", action="store_true", help="开启画面瑕疵局部模糊遮盖")
ap.add_argument("--ass", default=None,
help="用现成的对齐 ASS(align_subtitles.py 产出)烧字幕,跳过内置的设计时间轴。"
"强烈建议台词镜用这个——内置时间轴按 h3v3 设计秒数,会与口型错位")
ap.add_argument("--name", default=None)
a = ap.parse_args()
@@ -199,7 +202,19 @@ def main():
# 2) 烧字幕(单次编码)
ass_path = os.path.join(tmp, "ep.ass")
nsub = build_ass(timeline, ass_path)
if a.ass:
# 用对齐后的现成 ASS:先复制到 tmp 路径,避免改写用户源文件
import shutil
src_ass = os.path.abspath(a.ass)
if not os.path.exists(src_ass):
print("ERROR 缺 ASS", src_ass, file=sys.stderr); return 1
if os.path.abspath(ass_path) != src_ass:
shutil.copy(src_ass, ass_path)
nsub = sum(1 for l in open(ass_path, encoding="utf-8") if l.startswith("Dialogue:"))
print(" 字幕使用对齐 ASS: %s(%d 行)" % (src_ass, nsub), flush=True)
else:
nsub = build_ass(timeline, ass_path)
print(" ⚠ 使用内置设计时间轴字幕——可能与口型错位,建议改用 --ass + align_subtitles.py", flush=True)
video_only = os.path.join(tmp, "video_sub.mp4")
# concat demuxer
list_path = os.path.join(tmp, "concat.txt")