fix(gpu-direct): passthrough template title/subtitle/BGM config #2093

Merged
auto-approve-bot merged 1 commits from fix/gpu-direct-template-config-passthrough into develop 2026-09-29 14:54:34 +08:00
Owner

问题

GPU 直连渲染 MVP 硬编码标题/字幕/BGM 样式,模板配置字段被忽略:

  • P0 静态字幕(subtitle.text)完全丢失
  • P0 标题样式(font/size/color/position/stroke/shadow/bold)全部硬编码
  • P1 BGM volume 硬编码 0.35,无 fade/offset/adjust-db
  • P1 ASR 字幕样式(color/size/position/font)被忽略
  • P2 extra_audio_tracks(TTS/配音)volume 硬编码 1.0

修改

  1. build_direct_render 新增 title_config/subtitle_config/bgm_config/static_subtitle_text 参数
  2. 新增辅助函数:
    • _hex_to_drawtext_color:#RGB/#RRGGBB/#RRGGBBAA/命名颜色→drawtext颜色格式
    • _position_to_drawtext_xy:top/center/bottom → x/y 表达式
    • _build_drawtext_filters:阴影层(同字偏移)+ 主字层,支持 borderw/stroke 和 shadow
  3. 标题解析 font/size/color/position/stroke(→borderw/bordercolor)/shadow(→双层drawtext)/bold(→同色描边模拟),旧 title_text 兜底
  4. 字幕:静态 subtitle_text 构造全片长 segment(0→total_duration),与 ASR segments 共存时 ASR 优先;按 subtitle_cfg 设置 font/size/color/position/borderw
  5. BGM:读 volume(默认 0.3,clamp 0~1.5)、volume_adjust_db(线性增益)、fade_in/fade_out(afade)、audio_offset(adelay);enabled=false 时即使 path 存在也跳过
  6. _try_gpu_direct 整包透传 cfg[title]/[subtitle]/[bgm];非自动字幕时填 static_subtitle_text;extra_audio_tracks volume 从 audio_tracks_config 读取(配音)而非硬编码 1.0
  7. DirectRenderPlan 暴露 filter_complex 字段便于测试

测试

  • 新增 24 个单测(tests/unit/test_gpu_direct_pipeline.py):默认兼容/颜色HEX转换(短/长/alpha/非法)/位置top/center/bottom/描边/阴影双层/font覆盖/enabled开关/静态字幕全片长/ASR样式/BGM volume/fade/offset/adjust-db/enabled=false/extra音轨音量/粗体模拟/ASR优先静态/音量clamp
  • ruff check/format ✅,py_compile ✅,pytest 24 passed ✅

影响范围

仅 GPU 直连渲染路径(_try_gpu_direct),CPU 路径无改动;旧参数(title_text/tts_audio)保留兼容,不会回退。

## 问题 GPU 直连渲染 MVP 硬编码标题/字幕/BGM 样式,模板配置字段被忽略: - **P0** 静态字幕(subtitle.text)完全丢失 - **P0** 标题样式(font/size/color/position/stroke/shadow/bold)全部硬编码 - **P1** BGM volume 硬编码 0.35,无 fade/offset/adjust-db - **P1** ASR 字幕样式(color/size/position/font)被忽略 - **P2** extra_audio_tracks(TTS/配音)volume 硬编码 1.0 ## 修改 1. `build_direct_render` 新增 `title_config`/`subtitle_config`/`bgm_config`/`static_subtitle_text` 参数 2. 新增辅助函数: - `_hex_to_drawtext_color`:#RGB/#RRGGBB/#RRGGBBAA/命名颜色→drawtext颜色格式 - `_position_to_drawtext_xy`:top/center/bottom → x/y 表达式 - `_build_drawtext_filters`:阴影层(同字偏移)+ 主字层,支持 borderw/stroke 和 shadow 3. 标题解析 font/size/color/position/stroke(→borderw/bordercolor)/shadow(→双层drawtext)/bold(→同色描边模拟),旧 title_text 兜底 4. 字幕:静态 subtitle_text 构造全片长 segment(0→total_duration),与 ASR segments 共存时 ASR 优先;按 subtitle_cfg 设置 font/size/color/position/borderw 5. BGM:读 volume(默认 0.3,clamp 0~1.5)、volume_adjust_db(线性增益)、fade_in/fade_out(afade)、audio_offset(adelay);enabled=false 时即使 path 存在也跳过 6. `_try_gpu_direct` 整包透传 cfg[title]/[subtitle]/[bgm];非自动字幕时填 static_subtitle_text;extra_audio_tracks volume 从 audio_tracks_config 读取(配音)而非硬编码 1.0 7. `DirectRenderPlan` 暴露 filter_complex 字段便于测试 ## 测试 - 新增 24 个单测(tests/unit/test_gpu_direct_pipeline.py):默认兼容/颜色HEX转换(短/长/alpha/非法)/位置top/center/bottom/描边/阴影双层/font覆盖/enabled开关/静态字幕全片长/ASR样式/BGM volume/fade/offset/adjust-db/enabled=false/extra音轨音量/粗体模拟/ASR优先静态/音量clamp - ruff check/format ✅,py_compile ✅,pytest 24 passed ✅ ## 影响范围 仅 GPU 直连渲染路径(_try_gpu_direct),CPU 路径无改动;旧参数(title_text/tts_audio)保留兼容,不会回退。
xiaoxia added 1 commit 2026-09-29 14:44:38 +08:00
fix(gpu-direct): passthrough template title/subtitle/BGM config
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 51s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m49s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m32s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m6s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 3m18s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 3m38s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 3m45s
AI Code Review / AI Code Review (pull_request) Successful in 6m41s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 7m15s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 9m14s
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 1s
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 6m48s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 31s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 1m1s
11c554e43a
Problem: GPU direct render MVP hardcoded title/subtitle/BGM styles and
ignored template config fields:
- P0 static subtitle text (subtitle.text) was never rendered
- P0 title styles (font/size/color/position/stroke/shadow/bold) all hardcoded
- P1 BGM volume hardcoded at 0.35, no fade/offset/adjust-db
- P1 ASR subtitle styles (color/size/position/font) ignored
- P2 extra_audio_tracks (TTS/voiceover) volume hardcoded at 1.0

Changes:
1. build_direct_render() now accepts title_config/subtitle_config/
   bgm_config dicts + static_subtitle_text.
2. Added helpers _hex_to_drawtext_color (#RGB/#RRGGBB/#RRGGBBAA/named),
   _position_to_drawtext_xy (top/center/bottom), _build_drawtext_filters
   (shadow layer + main layer, stroke via borderw/bordercolor, bold
   simulated via same-color borderw).
3. Title parses font/size/color/position/stroke/shadow/bold with safe
   defaults; legacy title_text still used as fallback.
4. Static subtitle_text renders as full-span (0→total_duration) segment;
   when ASR segments are present they take priority.
5. BGM reads volume (default 0.3), volume_adjust_db (linear gain),
   fade_in/fade_out (afade), audio_offset (adelay ms|ms), and honors
   enabled=false even if path supplied. Volume clamped to [0,1.5].
6. _try_gpu_direct() now passes cfg['title']/['subtitle']/['bgm'] whole
   dicts through, computes static_subtitle_text for non-auto subs,
   and sources extra_audio_tracks volume from audio_tracks_config
   (voiceover tracks) instead of hardcoding 1.0.
7. DirectRenderPlan exposes filter_complex for testing.
8. Added 24 unit tests covering: default backward-compat, color hex/BGR
   conversion (short/long/alpha/invalid), position (top/center/bottom),
   stroke, shadow (two drawtext layers), font override, enabled flag,
   static subtitle full-span, ASR style passthrough, BGM
   volume/fade/offset/adjust-db/enabled=false, extra audio volume,
   bold simulation, ASR vs static priority, volume clamping.

Fixes template-style rendering not taking effect in GPU pipeline.

🚀 预览环境已部署

项目 详情
PR号 #2093
预览链接 https://pr-2093.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #2093 | | 预览链接 | [https://pr-2093.preview.xiaoxiajianji.com](https://pr-2093.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
auto-approve-bot merged commit da59a6c9a6 into develop 2026-09-29 14:54:34 +08:00
auto-approve-bot deleted branch fix/gpu-direct-template-config-passthrough 2026-09-29 14:54:36 +08:00

🗑️ 预览环境已清理

PR #2093 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #2093 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.