fix(worker): FFmpeg超时保护 - 防止渲染hang住导致worker永久阻塞 #242
Reference in New Issue
Block a user
Delete Branch "fix/ffmpeg-timeout-protection"
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?
背景
staging上新引擎第一次压测,worker渲染卡死。排查发现新引擎 UnifiedRenderService 所有 FFmpeg 调用通过
run_ffmpeg执行,但subprocess.run未设置timeout,FFmpeg hang住时worker线程永久阻塞。对比:旧引擎 compose_video 的 subprocess.run 有单独的
timeout=3600,但新引擎路径没有。根因
run_ffmpeg()无超时参数,subprocess.run无限等待修复
subprocess.TimeoutExpired并打 error 日志后重新抛出timeout=15s超时保护(ffprobe也可能hang)测试
- 新增 /internal/render/videos/{video_id}/download-url 接口:单个视频下载URL - 新增 /internal/render/tasks/{task_id}/videos 接口:任务下所有视频+下载URL - 内部 API Key 鉴权(X-API-Key),不对外开放 - 下载URL有效期24小时,方便对比工具批量下载 - 支持按 status 筛选(completed/failed 等) - 8个单元测试覆盖核心逻辑ffed853f6etoaca20d9bf0