perf: render-time cover frame pre-extraction + FFmpeg fallback, remove MediaKit #1360
Reference in New Issue
Block a user
Delete Branch "perf/cover-frame-pre-extract"
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?
Summary
Plan 2: Pre-extract cover frames during render
Plan 1: FFmpeg local fallback
Bug fix
Tests
Changed files
🚀 预览环境已部署
a59c9db81dto7ebff0dd62CI全绿,自动审批通过。
CI全绿,自动审批通过。
1caf9f3e42to823f3fb8a3【阻塞级判定】
📊 审查概览
🔴 阻塞级问题(必须修复)
无
💡 改进建议(不阻塞合并)
[packages/shared/ai_service.py: _extract_frames_with_ffmpeg] 抽帧数量与使用逻辑不匹配
_extract_frames_with_ffmpeg默认抽取 3 帧(num_frames=3),但在调用方_call_ai_cover_service中仅使用了frames[0]。如果第 1 帧抽取失败或质量不佳,代码并未尝试使用第 2、3 帧,导致额外的抽取开销浪费。num_frames参数改为 1 以提升性能;或者实现降级逻辑,在第 1 帧无效时尝试后续帧。[apps/api/app/api/routes/generation_cover.py: generate_cover] "ai_regenerate" 逻辑可能不符合用户预期
cover_type为ai_regenerate时,代码逻辑与ai_frame一致,直接返回预存的cover_candidates[0]。如果用户当前封面已经是该帧,再次点击“重新生成”将得到完全相同的结果,造成用户困惑。ai_regenerate分支下从候选列表中随机选择或排除当前已选帧;如果仅为了“确保有封面”,则当前逻辑没问题。✅ 良好实践
thumbnail_generator.py和ai_service.py中,对生成的临时文件(NamedTemporaryFile)均进行了显式的unlink清理,有效避免了磁盘空间泄漏。render_adapter.py中,封面候选帧的生成被包裹在try-except中且不阻断主流程,符合“非核心功能降级”的最佳实践。plan.config or {}和.get("key", default)进行了防御性编程,避免了潜在的NoneType错误。subprocess.run列表形式调用外部命令,有效防止了命令注入风险。✅ 格式检查通过 | ✅ 逻辑审查通过 | ✅ 性能无明显问题
🤖 由 AI 代码审查机器人自动生成 | 2026-08-13 12:36:58 | 模型:
🗑️ 预览环境已清理
PR #1360 已关闭或合并,对应的预览环境已被清理。