fix(worker): align gpu-direct title position/size with frontend preview #2095
Reference in New Issue
Block a user
Delete Branch "fix/gpu-direct-title-position-alignment"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
PR #2093 透传 title_config.position 后,GPU 直连路径实际渲染的标题位置/大小与前端预览不一致:top 贴顶偏上、竖屏偏小、custom 拖拽失效、默认跑到下边缘、粗体未生效。
根因(7 个子问题)
h*0.05(高度百分比),前端/CPU ASS 都按 video_width/720 等比缩放。1280×720 横屏 top y=40(baseline),字号 36 时中文字顶边约 40-30=10px,几乎出框;1080×1920 竖屏 y=96 而前端预览是 ~60px。margin_top=24@720p,用户拖动垂直间距完全没生效。bottom,schema / 剪辑页 / AI 头像页默认都top;未传字段时标题跑到下方。修复
_scale_title_len(v, video_width)按 720p 宽度等比缩放(对齐ass_subtitle_builder._scale_len和前端titleCanvas.ts的scale = videoWidth/720)。top→y = scale(PAD 16 + margin_top 默认 24) = scale(40) @720p(baseline;对齐前端firstLineY = size/2 + PAD + marginTop)bottom→y = h-th - scale(PAD 16 + margin_bottom 24)center→y=(h-text_h)/2(未变)custom→pos_x/pos_y(0-100%)→(w-text_w)*pct, (h-text_h)*pctmargin_top字段透传,默认 24@720p。top、默认 bold = True(仿粗描边宽度也缩放)。数值对比(1280×720)
备注
TITLE_MARGIN_TOP=180@720p明显偏大(25% 位置),可能是另一处遗留问题,本次不动 GPU 路径以外的逻辑,后续可单独排查。测试
🚀 预览环境已部署
🗑️ 预览环境已清理
PR #2095 已关闭或合并,对应的预览环境已被清理。