fix(ingest): separate ffprobe and ffmpeg timeout handling in HEVC transcode #1454
Reference in New Issue
Block a user
Delete Branch "fix/hevc-ffprobe-ffmpeg-timeout-separation"
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?
问题
ffprobe (timeout=10s) 和 ffmpeg (timeout=900s) 共用同一个 try/except 块。当 ffprobe 在大文件(4K HEVC)上超时时,TimeoutExpired 被错误捕获为"FFmpeg 转码超时",整个转码流程被跳过,HEVC 原文件直接入库。
修复
将原来的单个 try/except 拆分为 3 个独立块:
_needs_rotation=False,继续执行 ffmpeg日志精确区分:
ffprobe 旋转检测超时(60s),跳过旋转继续转码FFmpeg 转码超时(900s),降级原始文件验收标准
Problem: ffprobe (timeout=10s) and ffmpeg (timeout=900s) shared a single try/except block. When ffprobe timed out on large 4K HEVC files, the TimeoutExpired was caught as 'FFmpeg transcode timeout' and the entire transcode was skipped, leaving HEVC files unconverted. Fix: - Split into 3 independent try/except blocks: 1. Disk space check (warning-only, continues even on failure) 2. ffprobe rotation detection (timeout 10s -> 60s, failure sets _needs_rotation=False and continues to ffmpeg) 3. ffmpeg transcode (isolated, only catches its own errors) - Distinct log messages for each failure mode: - 'ffprobe 旋转检测超时(60s)' vs 'FFmpeg 转码超时(900s)' - ffprobe failure no longer blocks the entire transcode pipeline🚀 预览环境已部署
【阻塞级判定】
📊 审查概览
🔴 阻塞级问题(必须修复)
无
💡 改进建议(不阻塞合并)
2(GB) 和 ffprobe 超时时间60(秒)。建议将此类配置项提取为模块级常量或配置文件变量,便于后续维护和调整,例如MIN_DISK_FREE_GB = 2和FFPROBE_TIMEOUT = 60。✅ 良好实践
try/except块中,并设置为“失败不阻塞主流程”,这是一种很好的容错设计,避免了因辅助检查失败而导致整个转码任务中断。["ffprobe", ...])调用子进程,有效防范了命令注入风险。stderr的尾部内容输出,这能极大提升线上问题的排查效率。subprocess.TimeoutExpired进行了单独捕获,区分了超时和异常错误,逻辑更清晰。🤖 由 AI 代码审查机器人自动生成 | 2026-08-21 03:07:57 | 模型:
CI全绿,自动审批通过。
CI全绿,自动审批通过。
🗑️ 预览环境已清理
PR #1454 已关闭或合并,对应的预览环境已被清理。