Add raw-frame streaming endpoint to BaseVideo alongside MJPEG - #766
Conversation
- New /video.raw multipart endpoint: JSON FITS-keyed meta header + raw little-endian bytes, event-driven with latest-frame-wins backpressure. - VideoCapabilities.video -> mjpeg, add raw (both str | None); collapse live_view into video_path, add raw_path. - Split add_fits_headers() into add_local_fits_headers() (no VFS I/O) plus the persistent FRAMENUM step; guard the per-frame centre warning. - Add Image.from_ndarray() reconstruction helper. - Fix video_handler's hardcoded 1 fps interval; lower sleep_time default to 60s.
Code reviewFound 6 issues, most-severe first.
pyobs-core/pyobs/modules/camera/basevideo.py Lines 275 to 280 in 85d6374
pyobs-core/pyobs/modules/camera/basevideo.py Lines 316 to 319 in 85d6374
pyobs-core/pyobs/modules/camera/basevideo.py Lines 316 to 319 in 85d6374
pyobs-core/pyobs/modules/camera/basevideo.py Lines 324 to 327 in 85d6374
pyobs-core/pyobs/modules/camera/basevideo.py Lines 335 to 340 in 85d6374
pyobs-core/specs/plans/2026-08-11-basevideo-raw-frame-streaming.md Lines 70 to 76 in 85d6374 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
|
Thanks, useful review. I agree with 1, 2, and 6 and will fix those. Pushing back on 4 and 5, and 3 is real but has a tradeoff.
|
|
Agreed, that's the right split. One consequence worth stating up front for #1: refreshing |
…ocument sleep_time trade-off Addresses review findings on #766: - raw_handler now bounds its wait on a new frame with a timeout, re-touching _active_time even when no frame arrives, so a connected-but-idle raw client can no longer let the camera sleep out from under it. - DATE-OBS is now captured in _set_image() at acquisition time instead of at send time in _raw_frame(), avoiding drift under frame coalescing or scheduling delay. - Documents the sleep_time default's cost trade-off in a code comment, as the plan required.
# Conflicts: # pyobs/modules/camera/basevideo.py
* Add raw-frame streaming endpoint to BaseVideo alongside MJPEG - New /video.raw multipart endpoint: JSON FITS-keyed meta header + raw little-endian bytes, event-driven with latest-frame-wins backpressure. - VideoCapabilities.video -> mjpeg, add raw (both str | None); collapse live_view into video_path, add raw_path. - Split add_fits_headers() into add_local_fits_headers() (no VFS I/O) plus the persistent FRAMENUM step; guard the per-frame centre warning. - Add Image.from_ndarray() reconstruction helper. - Fix video_handler's hardcoded 1 fps interval; lower sleep_time default to 60s. * Fix raw-handler activity liveness, capture DATE-OBS at acquisition, document sleep_time trade-off Addresses review findings on #766: - raw_handler now bounds its wait on a new frame with a timeout, re-touching _active_time even when no frame arrives, so a connected-but-idle raw client can no longer let the camera sleep out from under it. - DATE-OBS is now captured in _set_image() at acquisition time instead of at send time in _raw_frame(), avoiding drift under frame coalescing or scheduling delay. - Documents the sleep_time default's cost trade-off in a code comment, as the plan required.
Implements the
basevideo-raw-frame-streamingplan/design.What
/video.rawmultipart endpoint: JSON FITS-keyed meta header (X-Pyobs-Frame-Meta) + raw little-endian bytes, event-driven via a newasyncio.Eventwith latest-frame-wins backpressure (coalesces bursts into a single wake).VideoCapabilities.videorenamed tomjpeg, plus a newrawfield (bothstr | None). Collapsedlive_view+video_pathinto a singlevideo_path: str | None, addedraw_path: str | None./,/video.mjpg, and/video.rawroutes are now registered only when their path is configured.add_fits_headers()intoadd_local_fits_headers()(no VFS I/O) plus the persistent FRAMENUM VFS step, so the raw path builds headers without per-frame VFS writes.Image.from_ndarray()reconstruction helper (consumer side of the wire contract).video_handler's hardcoded 1 fps interval (now usesself._interval).sleep_timedefault 600s -> 60s.DET-CPXwarning (it fired every frame whencentreis unset).Breaking changes
VideoCapabilities.videoremoved in favor ofmjpeg/raw.BaseVideo(live_view=...)removed; usevideo_path=Noneto disable the MJPEG live view.Both acceptable per the plan (project is
2.0.0.dev).Tests
Added coverage for: capability round-trip (XML), route gating,
_new_frameset + coalescing, raw meta/little-endian framing, raw handler wake/write + activity,add_local_fits_headersVFS-free, andImage.from_ndarray.