feat: #1970 hflip 按 atom_clip ai_tags.has_text 放开 + 清理重复 081 migration
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 2m44s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 3m37s
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 2m34s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
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 / PR Build Worker Image (pull_request) Successful in 26s
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 / Retag skipped Staging Web 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 1m39s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 4m7s
CI/CD Pipeline / Validate - Style (pull_request) Failing after 4m43s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 4m58s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 11m18s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 11m37s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
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 / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Failing after 1s
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped

- render_adapter 按非 audio 源片段顺序批量查 atom_clip.ai_tags,
  仅 has_text 显式 false 标记无文字,其余(未打标签/true/null/查询失败)保守不翻转
- UnifiedRenderService 新增 clip_has_text 注入,None 维持 P1 全保守语义
- 删除残留 081_atom_clip_ai_tags.py(与 GPU PR 的 081 撞号,内容已由 082 承载),
  develop alembic 恢复单 head:080→081_add_gpu_lipsync→082_atom_clip_ai_tags
- 新增 19 个测试(纯函数混合标记/服务门控/适配器解析/失败回退),全量 15819 passed
This commit is contained in:
xiaoxia
2026-09-19 01:06:46 +08:00
parent 9af73dcd86
commit fbd89b4089
5 changed files with 235 additions and 28 deletions
@@ -493,6 +493,41 @@ class RenderAdapter:
logger.warning("ASR 服务初始化失败,自动字幕将不可用: %s", e)
return None
def _resolve_clip_has_text(self, clips: list[Any]) -> list[bool] | None:
"""#1970:按源视频片段顺序解析 atom_clip.ai_tags.has_text。
顺序与 UnifiedRenderService 的「非 audio 源片段」口径一致。
仅当 atom_clip 存在 ai_tags 字典且 has_text 显式为 False 时标记为
无文字(允许 hflip);atom_clip_id 缺失、ai_tags 未生成、has_text 为
true/null/非布尔值时一律按有文字处理(保守不翻转)。
查询失败时返回 None,渲染层回退到全保守路径。
"""
video_clips = [c for c in clips if getattr(c, "clip_type", "main") != "audio"]
atom_ids: list[str] = []
seen: set[str] = set()
for c in video_clips:
atom_id = getattr(c, "atom_clip_id", "") or ""
if atom_id and atom_id not in seen:
seen.add(atom_id)
atom_ids.append(atom_id)
if not atom_ids:
return None
try:
from packages.adapters.sqlalchemy_impl.asset_atom_clip_repository import (
SQLAlchemyAssetAtomClipRepository,
)
atom_clips = SQLAlchemyAssetAtomClipRepository(self._db).find_by_ids(atom_ids)
except Exception as exc:
logger.warning("[render-adapter] atom_clip ai_tags 查询失败,hflip 全量保守处理: %s", exc)
return None
has_text_map: dict[str, bool] = {}
for ac in atom_clips:
ai_tags = getattr(ac, "ai_tags", None)
no_text = isinstance(ai_tags, dict) and ai_tags.get("has_text") is False
has_text_map[ac.id] = not no_text
return [has_text_map.get((getattr(c, "atom_clip_id", "") or ""), True) for c in video_clips]
def _do_render(
self,
plan: Any,
@@ -542,6 +577,7 @@ class RenderAdapter:
)
# 4. 执行统一渲染
clip_has_text = self._resolve_clip_has_text(clips)
render_svc = UnifiedRenderService(
plan=plan,
clips=clips,
@@ -552,6 +588,7 @@ class RenderAdapter:
bgm_path=bgm_path,
asr_service=asr_service,
voiceover_audio_path=voiceover_audio_path,
clip_has_text=clip_has_text,
)
result = render_svc.render()