feat: video analysis switched to push mode (upload whole video, sync response)
Rationale: Oracle cannot reach NAS (Tailscale userspace mode on NAS, no TUN), the old pull+webhook design requires Edge to download video from NAS and callback to NAS - both blocked. New design is one-way NAS -> Oracle: - FAM-Edge: new POST /api/edge/video/push endpoint accepts multipart video upload, reuses existing OpenCV scene-change keyframe selection, analyzes synchronously and returns the result payload directly in the HTTP response (no webhook callback). Old /api/edge/video/analyze kept for compatibility. - FAM-Edge: VideoPreprocessor.save_upload() saves the uploaded file - FAM-Edge: AIOrchestrator.process_push_task() runs the full pipeline (health check -> extract -> select -> compress -> VLM -> fusion) and returns callback-style payload dict - FAM-Core: Dispatcher rewritten to push mode - reads local video file, uploads with task metadata (camera_name, event_start_time from file mtime, known_members_context), applies the result to DB via shared event_receiver.apply_success_event() - FAM-Core: event_receiver success logic extracted into reusable apply_success_event() (used by both webhook route and dispatcher) - config: edge_url -> /api/edge/video/push, push_timeout 1800s, gunicorn Edge timeout raised to 1800s for long synchronous analysis
This commit is contained in:
@@ -68,6 +68,17 @@ class VideoPreprocessor:
|
||||
log_task(logger, self.task_id, 'download', f'下载完成: {size_mb:.1f}MB', duration_ms=duration_ms)
|
||||
return self.video_path
|
||||
|
||||
def save_upload(self, file_storage) -> str:
|
||||
"""保存推送模式上传的视频文件(multipart),替代 download_video"""
|
||||
os.makedirs(self.work_dir, exist_ok=True)
|
||||
start = time.time()
|
||||
file_storage.save(self.video_path)
|
||||
duration_ms = int((time.time() - start) * 1000)
|
||||
size_mb = os.path.getsize(self.video_path) / (1024 * 1024)
|
||||
log_task(logger, self.task_id, 'upload',
|
||||
f'保存上传视频: {size_mb:.1f}MB', duration_ms=duration_ms)
|
||||
return self.video_path
|
||||
|
||||
def _get_video_duration(self, video_path: str) -> float:
|
||||
"""用 ffprobe 获取视频时长(秒)"""
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user