This commit is contained in:
zaiun xu
2026-04-13 17:13:02 +08:00
parent 6f006def64
commit c1aafc69bf
8 changed files with 580 additions and 66 deletions

View File

@@ -56,20 +56,38 @@ async def _run_inference_and_state(
async with app_state.action_lock:
app_state.action_status = "running"
try:
snap = await asyncio.to_thread(action_svc.run_full_action, mp4, settings)
if health_snapshot_deliverable(snap):
save_health_snapshot(settings, snap, source_path=key)
else:
# 返回 (第一个快照, 所有切片快照列表)
first_snap, all_snaps = await asyncio.to_thread(
action_svc.run_full_action, mp4, settings
)
# 将所有切片作为独立视频保存到数据库
saved_count = 0
for i, snap in enumerate(all_snaps):
if health_snapshot_deliverable(snap):
# 为每个切片生成独立的 source_path
slice_key = f"{key}#slice{i}"
save_health_snapshot(settings, snap, source_path=slice_key)
saved_count += 1
if saved_count == 0:
logger.warning(
"[action-watch] no deliverable health snapshot for {}, skip SQLite",
mp4.name,
)
app_state.action_status = "idle"
processed.add(key)
if settings.action_watch_use_state_file:
add_watch_processed(settings, key, "action")
pred = (snap.raw_class_en or "").strip()
logger.info("[action-watch] done: {} -> {}", mp4.name, pred)
pred = (first_snap.raw_class_en or "").strip()
logger.info(
"[action-watch] done: {} -> {} (saved {} slices)",
mp4.name,
pred,
saved_count,
)
except Exception as e:
logger.exception("[action-watch] error on {}: {}", mp4, e)
app_state.action_status = "idle"