feat(v1): latest-frame-only reader thread for low-latency RTSP
Adds _FrameGrabber which decodes in a background thread and keeps only the newest frame; VideoSource drop_stale (STREAM only) returns the latest frame so a slow consumer never builds a backlog. app enables it for streams. REPLAY is unchanged. 82 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -388,3 +388,12 @@
|
||||
- 阻塞:真实线程整合需 Windows 冒烟;最新帧保留核心 `_pump` 逻辑本环境可确定性测。
|
||||
- 决策:读帧解码放后台线程、消费端只取最新帧、丢弃积压,使延迟不随推理速度增长且被钳在一次推理量级;REPLAY 保持逐帧不丢;STREAM 用收帧时单调时钟。
|
||||
- 下一步:写 `_FrameGrabber._pump` 只留最新帧的失败测试,再实现并在 app 对 STREAM 开启。
|
||||
|
||||
## 【2026-07-22】T-212 实时流只处理最新帧降延迟(完成)
|
||||
|
||||
- 状态:DONE
|
||||
- 变更:`video_source.py` 新增 `_FrameGrabber`(daemon 线程,持续 `cap.read()` 只保留最新帧、丢弃积压,读失败置 failed,读异常不崩线程)。`VideoSource` 增 `drop_stale`(仅 STREAM 生效):懒开流后启动 grabber,`read()` 返回最新帧(无帧时 RETRYING/connecting,failed 则释放+有界退避重连),`close()` 停 grabber。`app.py` 对 STREAM 开启 `drop_stale=True`。REPLAY 路径不变(逐帧不丢)。
|
||||
- 验证:新增测试——`_FrameGrabber._pump` 连续三帧后 `take_latest` 只留最新(丢弃前两帧)、读失败置 failed;STREAM+drop_stale 集成(真实线程)在轮询内返回 CONNECTED 帧。`python3 -m pytest v1/tests -q` 为 82 passed;`python3 -m compileall -q v1` 退出码 0。
|
||||
- 阻塞:真实 RTSP 上的端到端延迟改善需 Windows 目视确认;丢弃最新帧核心逻辑与集成本环境已测。
|
||||
- 决策:解码放后台线程、消费端只取最新帧,使延迟被钳在一次推理量级、不随推理速度增长;STREAM 用收帧时单调时钟,丢帧不破坏摔倒计时(每处理帧取真实到达时间)。
|
||||
- 下一步:T-213 截图中文标注(Pillow,缺库/字体回退 ASCII)。
|
||||
|
||||
Reference in New Issue
Block a user