Files
xiaoxia-saas/apps/worker/viral_video/__init__.py
T
xiaoxia 4657ededfe
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 2s
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 2s
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 / Validate - Security (pull_request) Failing after 1s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m53s
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 4m18s
CI/CD Pipeline / Retag skipped Staging API 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 Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Validate - Style (pull_request) Has been cancelled
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Has been cancelled
CI/CD Pipeline / Unit Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build API Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been cancelled
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been cancelled
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / Build Production API Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Web Image (pull_request) Has been cancelled
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been cancelled
CI/CD Pipeline / Deploy Production (pull_request) Has been cancelled
CI/CD Pipeline / Production Browser E2E (pull_request) Has been cancelled
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been cancelled
CI/CD Pipeline / Canary Release to Production (pull_request) Has been cancelled
CI/CD Pipeline / CI Gate (pull_request) Has been cancelled
CI/CD Pipeline / Integration Tests (pull_request) Has been cancelled
CI/CD Pipeline / PR Build Worker Image (pull_request) Has been cancelled
AI Code Review / AI Code Review (pull_request) Has been cancelled
PR Automation / Auto Merge on CI Green + Approved (pull_request) Has been cancelled
feat(worker): 参考视频风格分析模块 video_analyzer (#2051)
实现 v1.3 爆款视频参考风格分析 6 步管线:
  ① FFmpeg 抽关键帧(每 2s 一帧 + 场景切换帧)
  ② PySceneDetect ContentDetector(threshold=27) 镜头分割
  ③ OpenCV Farneback 光流运镜检测(推/拉/摇/移/zoom/static + 强度)
  ④ librosa BPM 分析(>110 fast_cut / 80-110 medium / <80 slow_cinematic)
  ⑤ OSS 上传关键帧 + 豆包 VLM 色调/构图/光线分析
  ⑥ 豆包 LLM 整合 style_guide JSON(失败走规则合成降级)

新增渲染参数映射:
- 运镜 → ken_burns 参数(push_in→zoom_in_slow、tilt_up→pan+zoom 等 11 种)
- 转场 → TransitionEngine xfade 名称(hard_cut→cut/dissolve/wipeleft 等)
- 色调 → FFmpeg eq + colorchannelmixer 预设(5 套:warm_vintage/cool_fresh/high_contrast/soft_pastel/dramatic_cinematic)
- BPM → BGM 选曲 BPM±5 提示
- build_render_params_for_clip() 按镜头索引聚合可直接喂 URS 的参数

降级链:
- FFmpeg 抽帧失败 → VLM 路径;OpenCV 不可用 → static/low;librosa 不可用 → VLM 估计;
- LLM/VLM 不可用 → 规则合成 style_guide;任意子步骤异常不抛,best-effort 返回最小可用 style_guide。

资源约束:参考视频 ≤60s/≤100MB,总超时 60s,临时帧 try/finally 清理。
依赖新增:scenedetect==0.6.4、librosa==0.10.2.post1、soundfile==0.12.1(requirements-worker.txt)。
orchestrator 改为从 apps.worker.viral_video.video_analyzer 导入 analyze_video_style,
传入 style_strength 透传 light/medium/strict 三档。
单测 48 条覆盖:映射函数/光流运镜判定/BPM 档位/规则合成/聚合输出/降级/临时文件清理。
2026-09-29 20:41:24 +08:00

34 lines
973 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""爆款视频 Worker 侧模块(#2039/#2040/#2051)。
video_analyzer(#2051):参考视频风格分析 6 步管线,输出 style_guide + clips 渲染参数映射。
#2040 的 prompt 系统(prompts/prompt_store/llm_runner)由 #2040 分支提供,本文件不依赖它。
"""
from __future__ import annotations
from apps.worker.viral_video.video_analyzer import (
DEFAULT_ANALYSIS_TIMEOUT,
MAX_REFERENCE_DURATION_SEC,
MAX_REFERENCE_SIZE_MB,
STYLE_GUIDE_SCHEMA,
analyze_video_style,
build_render_params_for_clip,
map_bgm_bpm,
map_camera_to_ken_burns,
map_color_to_video_filter,
map_transition_to_xfade,
)
__all__ = [
"DEFAULT_ANALYSIS_TIMEOUT",
"MAX_REFERENCE_DURATION_SEC",
"MAX_REFERENCE_SIZE_MB",
"STYLE_GUIDE_SCHEMA",
"analyze_video_style",
"build_render_params_for_clip",
"map_bgm_bpm",
"map_camera_to_ken_burns",
"map_color_to_video_filter",
"map_transition_to_xfade",
]