perf(#1280): 预览视频生成加速 — ultrafast编码+并行下载+跳过非必要步骤 (#1284)
CI/CD Pipeline / Validate - Migration (alembic) (push) Successful in 1m16s
CI/CD Pipeline / Validate - Type Check (mypy) (push) Successful in 1m16s
CI/CD Pipeline / Build Staging Web Image (push) Successful in 2m29s
CI/CD Pipeline / Frontend Unit Tests (push) Successful in 3m3s
CI/CD Pipeline / Build Staging Worker Image (push) Successful in 5m3s
CI/CD Pipeline / Validate - Code Quality (push) Successful in 5m35s
CI/CD Pipeline / Integration Tests (push) Successful in 2m37s
CI/CD Pipeline / Unit Tests (push) Successful in 9m57s
CI/CD Pipeline / Build Staging API Image (push) Successful in 12m44s
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (push) Successful in 1m28s
CI/CD Pipeline / Staging API Integration Tests (push) Failing after 17s
CI/CD Pipeline / Staging E2E Tests (push) Failing after 17s
CI/CD Pipeline / ACR Image Cleanup (push) Successful in 34s
CI/CD Pipeline / Canary Release to Production (push) Failing after 953h20m32s
CI/CD Pipeline / PR Build Web Image (push) Failing after 953h35m2s
CI/CD Pipeline / Production Browser E2E (push) Failing after 953h25m3s
CI/CD Pipeline / PR Build API Image (push) Failing after 953h35m3s
CI/CD Pipeline / Deploy Production (push) Failing after 953h25m3s
CI/CD Pipeline / CI Gate (push) Failing after 953h25m5s
CI/CD Pipeline / Check if frontend-only change (push) Failing after 953h35m7s
CI/CD Pipeline / Build Production Worker Image (push) Failing after 953h25m5s
CI/CD Pipeline / Build Production Web Image (push) Failing after 953h25m5s
CI/CD Pipeline / Build Production API Image (push) Failing after 953h25m5s
CI/CD Pipeline / PR Build Worker Image (push) Failing after 954h8m23s
CI/CD Pipeline / Frontend Lint (push) Failing after 954h8m26s

This commit was merged in pull request #1284.
This commit is contained in:
2026-08-07 21:52:03 +08:00
parent 5abadd053a
commit 60e8cd5247
4 changed files with 407 additions and 78 deletions
+35 -29
View File
@@ -485,6 +485,7 @@ class RenderAdapter:
rendered_clip_ids: list[str] | None = None,
failed_clip_ids: list[str] | None = None,
voiceover_audio_path: str | None = None,
is_preview: bool = False,
) -> RenderAdapterResult:
"""执行统一渲染核心流程(BGM + ASR + 渲染 + 缩略图 + 上传)。
@@ -503,8 +504,8 @@ class RenderAdapter:
self._report_progress(progress_cb, 40.0, "执行视频渲染")
# 2. 初始化 ASR
asr_service = self._get_asr_service()
# 2. 初始化 ASR(预览模式跳过,节省启动开销)
asr_service = None if is_preview else self._get_asr_service()
# 3. 读取输出分辨率
plan_config = plan.config or {}
@@ -529,25 +530,27 @@ class RenderAdapter:
bgm_path=bgm_path,
asr_service=asr_service,
voiceover_audio_path=voiceover_audio_path,
is_preview=is_preview,
)
result = render_svc.render()
# 4.5 渲染后校验输出完整性
validation = validate_video_output(result.output_path)
if not validation.valid:
logger.error(
"[render-adapter] 渲染输出校验失败: plan_id=%s job_id=%s error=%s",
plan_id,
job_id,
validation.error_message,
)
return RenderAdapterResult(
success=False,
error_message=f"渲染输出校验失败: {validation.error_message}",
error_detail=validation.error_message,
)
# 4.5 渲染后校验输出完整性(预览模式跳过,节省耗时)
if is_preview:
logger.info("[render-adapter] 预览模式:跳过输出校验")
else:
validation = validate_video_output(result.output_path)
if not validation.valid:
logger.error(
"[render-adapter] 渲染输出校验失败: plan_id=%s job_id=%s error=%s",
plan_id,
job_id,
validation.error_message,
)
return RenderAdapterResult(
success=False,
error_message=f"渲染输出校验失败: {validation.error_message}",
error_detail=validation.error_message,
)
self._report_progress(progress_cb, 80.0, "上传渲染结果")
# 5. 上传结果
@@ -556,19 +559,20 @@ class RenderAdapter:
self._report_progress(progress_cb, 90.0, "生成封面缩略图")
# 6. 生成缩略图
# 6. 生成缩略图(预览模式跳过,节省耗时)
thumbnail_url = ""
try:
from video_processing.thumbnail_generator import generate_and_upload_thumbnail
if not is_preview:
try:
from video_processing.thumbnail_generator import generate_and_upload_thumbnail
thumb_storage_key = f"rendered/{plan_id}/thumbnail.jpg"
thumbnail_url = generate_and_upload_thumbnail(str(result.output_path), thumb_storage_key)
except Exception as thumb_err:
logger.warning(
"[render-adapter] 缩略图生成失败(不影响主流程): plan_id=%s error=%s",
plan_id,
thumb_err,
)
thumb_storage_key = f"rendered/{plan_id}/thumbnail.jpg"
thumbnail_url = generate_and_upload_thumbnail(str(result.output_path), thumb_storage_key)
except Exception as thumb_err:
logger.warning(
"[render-adapter] 缩略图生成失败(不影响主流程): plan_id=%s error=%s",
plan_id,
thumb_err,
)
self._report_progress(progress_cb, 100.0, "渲染完成")
@@ -614,6 +618,7 @@ class RenderAdapter:
work_dir: Path | None = None,
progress_cb: ProgressCallback | None = None,
voiceover_audio_path: str | None = None,
is_preview: bool = False,
) -> RenderAdapterResult:
"""使用内存中的 plan/clips/asset_path_map 直接渲染。
@@ -672,6 +677,7 @@ class RenderAdapter:
job_id=job_id,
progress_cb=progress_cb,
voiceover_audio_path=voiceover_audio_path,
is_preview=is_preview,
)
except subprocess.CalledProcessError as exc: