wiki: camera live view decision; MJPEG install step; park-lab camera addresses vs 11-15 record
Build & push images / images (push) Successful in 4m31s
Build & push images / images (push) Successful in 4m31s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
---
|
||||
type: decision
|
||||
tags: [parking, camera, ui, booth, video, hikvision]
|
||||
sources: []
|
||||
updated: 2026-11-17
|
||||
status: settled
|
||||
---
|
||||
|
||||
# Camera Live View — Booth Camera Tiles
|
||||
|
||||
The booth operator can open a small tile per camera from the [[device-status-monitoring|device
|
||||
footer]] and watch that camera live while a vehicle is in front of it. **BUILT 2026-11-17**;
|
||||
verified end to end against the two park-lab cameras through the real server and in a browser
|
||||
(not yet in the [[desktop-shell-tauri|desktop shell]] — see *Not yet verified*).
|
||||
|
||||
## What the user asked for (2026-11-17)
|
||||
|
||||
- The camera chips in the footer are clickable; a click opens that camera's tile in the bottom
|
||||
right, about 15 % of the screen wide. A second camera's tile stacks to the **left** of the first.
|
||||
- A tile closes with ✕; which tiles are open is a **user preference** (restored on login).
|
||||
- A tile rests on the **latest entry/exit snapshot** of that camera; when the camera's vehicle
|
||||
events reach the booth, it shows **live video**.
|
||||
|
||||
## Decision
|
||||
|
||||
| Question | Choice | Why |
|
||||
|---|---|---|
|
||||
| Video source | The camera's **sub-stream (x02) set to MJPEG**, pulled over **RTSP** | The G2 firmware answers the HTTP MJPEG preview (`/ISAPI/Streaming/channels/102/httpPreview`) with `notSupport`; RTSP offers MJPEG as RTP/JPEG (RFC 2435). Every MJPEG frame is a whole picture, so a view is live ~150 ms after connect — H.264 would wait for a keyframe (every 2.5–4 s on these cameras) and need a decoder. |
|
||||
| Where it runs | **In the server process**, as a driver capability (`LiveStreamDevice`) in `packages/devices` | No sidecar container (camera config + `localAddress` already live in the DB; the [[device-adapter-pattern]] keeps the protocol in the driver). The server reassembles JPEG frames from RTP packets — about 450 small packets/s for two cameras; it never decodes or re-encodes. |
|
||||
| Fan-out | **One RTSP session per camera**, shared by every viewer, torn down 5 s after the last leaves | A camera has few stream slots and the [[lane-presence-and-anpr-entry|ANPR loop]] pulls stills from the same unit. |
|
||||
| Delivery to the page | A **WebSocket per open tile** (`/api/cameras/:id/live`), one JPEG per binary message, **latest frame only**, capped at 10 fps per viewer | Works in the desktop shell, whose webview cannot carry the session cookie on an `<img>`/`<video>` request (the WS already solves that with a ticket). A viewer whose socket still holds > 256 KB unsent skips frames — server memory stays bounded. |
|
||||
| When live | **Per camera**, while that camera pushes vehicle events (same 30 s TTL as lane busy/free) | On a shared lane (park-lab) only the camera that saw the car goes live; lane state would light both. |
|
||||
| Auth | Same handshake as `/api/ws` (Origin allowlist, then desktop ticket or cookie), then `device:read` | One helper (`authenticateWsHandshake`) for every socket route, so they cannot drift. The resting snapshot needs `session:read` (it is evidence). |
|
||||
| Preference | `users.open_cameras` (JSON id list, migration 0033), `PUT /api/auth/open-cameras` | Same shape as language / theme / font scale. |
|
||||
|
||||
**Advisory viewing only.** Nothing here writes to the ledger, gates a ticket or opens a barrier.
|
||||
|
||||
### Not a reversal of the "livestream" rejection
|
||||
|
||||
[[lane-presence-and-anpr-entry]] rejected *vision monitoring the RTSP livestream continuously for
|
||||
presence* — inference on every frame, 24/7. This is an operator **watching** video, only while a
|
||||
vehicle is present, with no inference at all.
|
||||
|
||||
## Measured on park-lab (2026-11-17)
|
||||
|
||||
Cameras (read from `ISAPI/System/deviceInfo` the same day): `10.0.10.6` entry =
|
||||
**DS-2CD1083G2-LIU** (8MP, V5.8.4), `10.0.10.7` exit = **DS-2CD1043G2-LIU** (4MP, V5.8.10).
|
||||
Both offer `H.264, H.265, MJPEG` on channel 102 and only two streams (101, 102). Channel 102 on
|
||||
both was switched from H.264 to **MJPEG** (640×360; other settings unchanged) with the user's
|
||||
agreement.
|
||||
|
||||
- **RTSP:** first frame 110–155 ms after PLAY; `.6` 12.5 fps ≈ 310 KB/s, `.7` 20 fps ≈ 270 KB/s;
|
||||
RFC 2435 type 1 (4:2:0), Q 63 / 48 (no in-band tables), no restart markers, padding on each
|
||||
frame's last packet. `Session: …;timeout=60`; a 150 s session ran without drops with and
|
||||
without keepalive (a `GET_PARAMETER` is sent every timeout/2 anyway).
|
||||
- **Interference with ANPR stills** (what was measured — one camera at a time, one stream):
|
||||
- main-stream stills (`101/picture`, back-to-back, ~15–20 s) with an RTSP stream starting
|
||||
mid-run: `.6` 0/87 → 0/110 HTTP 503; `.7` 4/55 → 4/71 (the `.7` 503s occur without the
|
||||
stream too — the transient `deviceBusy` the driver retries). Starting a stream added none.
|
||||
- sub-stream stills (`102/picture`, back-to-back) while 102 streams MJPEG over RTSP for 180 s:
|
||||
`.6` 2121/2121 and `.7` 3187/3187 HTTP 200 (baselines without the stream, 60 s: 672/672 and
|
||||
594/594); the stream held 12.0 / 20.0 fps throughout.
|
||||
- Not measured: several live sessions on one camera at once (the hub opens one), a stream
|
||||
alongside a browser left on the camera's web UI, and the G3H model.
|
||||
- `102/picture` returns a 640×360 JPEG after the codec switch.
|
||||
- **End to end** (server + scratch DB + both cameras, 2026-11-17): a simulated vehicle push →
|
||||
`camera-activity` on `/api/ws`; two viewers on the entry camera and one on the exit camera went
|
||||
`connecting → live` in 151 / 181 ms, 8–10 fps each, zero malformed JPEGs.
|
||||
|
||||
## Install step (new)
|
||||
|
||||
Set the camera's **sub-stream (102) video encoding to MJPEG** (web UI: Configuration → Video/Audio
|
||||
→ Video → Sub Stream, or `PUT /ISAPI/Streaming/channels/102` with `videoCodecType=MJPEG`). With
|
||||
H.264 the tile says *"camera stream is H264, not MJPEG"* and stays on the snapshot. Added to
|
||||
[[site-device-installation]] §3. On a camera whose snapshot stream is set to **Sub** (the G3H
|
||||
workaround), the sub-stream resolution is both the ANPR/evidence still and the live view — MJPEG on
|
||||
the G2 offers 640×360, 640×480 or 1280×720 on channel 102; raising it costs bandwidth (~300 KB/s
|
||||
at 640×360). Dahua cameras have no live view yet (tile shows the reason).
|
||||
|
||||
## Consequences elsewhere
|
||||
|
||||
- [[passage-confirmation]] planned to decode the **H.264** sub-stream. On a camera set up for live
|
||||
view that stream is now MJPEG: OpenCV decodes it too, every frame is a keyframe (the "≤ 1 s
|
||||
I-frame" requirement disappears), at ~5–10× the bandwidth (~300 KB/s per camera on the device
|
||||
VLAN). The two consumers should share one RTSP session per camera when that is built.
|
||||
- **Unverified, probably broken today:** the existing snapshot thumbnails
|
||||
(`SnapshotStrip`, `WashDesk`) use `<img src="/api/snapshots/:id">` — a relative, cookie-authed
|
||||
URL that the desktop shell's webview cannot authenticate. The camera tile fetches its snapshot
|
||||
through `platformFetch` instead. Check on a desktop install.
|
||||
|
||||
## Verified in a browser (2026-11-17)
|
||||
|
||||
Headless Firefox against the server with both park-lab cameras and a simulated vehicle push:
|
||||
footer chips open tiles bottom-right (≈ 15 % wide, first opened rightmost, next to its left), each
|
||||
resting on its camera's latest snapshot with direction and time; after the entry camera's push only
|
||||
the entry tile went **LIVE** (live OSD clock); a reload restored both tiles; ✕ closed one and the
|
||||
saved preference followed.
|
||||
|
||||
## Not yet verified
|
||||
|
||||
- The Tauri/WebKitGTK shell (binary WS frames through `@tauri-apps/plugin-websocket` arrive as a
|
||||
number array over IPC — fine at 10 fps × 25 KB, to be measured). Its CSP already allows `blob:`
|
||||
images.
|
||||
- Through Caddy (`reverse_proxy` upgrades WebSockets; not exercised).
|
||||
- The live → snapshot return 30 s after the last push in the browser (covered by unit tests only).
|
||||
- A real vehicle push from the cameras (park-lab's alarm server is not set yet — see
|
||||
[[passage-confirmation]] park-lab rig).
|
||||
|
||||
## Where the code is
|
||||
|
||||
`packages/devices/src/drivers/rtsp-mjpeg.ts` (RTSP client), `rfc2435.ts` (frame reassembly,
|
||||
fixture-tested against frames verified with a JPEG decoder), `camera.ts` (`openLiveStream` on
|
||||
Hikvision); `apps/server/src/camera-live.ts` (hub), `camera-activity.ts`, `routes/cameras.ts`;
|
||||
`apps/web/src/ui/CameraDock.tsx`, `ui/DeviceFooter.tsx`. Knob: `CAMERA_LIVE_MAX_FPS` (10).
|
||||
Reference in New Issue
Block a user