cameras/scripts/install-mediamtx.mts
Michael Mainguy 5824db8ea9 Add MediaMTX video bridge: pinned installer and supervised localhost process
- npm run video:install downloads the pinned MediaMTX v1.21.0 for this
  platform, verifies its SHA-256 against checksums committed in
  src/lib/mediamtx-install.ts, and installs it into gitignored bin/.
- On server start, instrumentation launches MediaMTX with a generated
  owner-only config: API and WebRTC signaling on 127.0.0.1, only the ICE
  port (UDP 8189) on the LAN, a hashed per-boot API password, no
  anonymous users, unused protocols off. Restarts on crash with backoff,
  stops with the server; VIDEO_BRIDGE=off skips it.
- Camera streams are added to MediaMTX at runtime, on demand, with the
  stored login; nothing with a password is written to disk or echoed.
- rtspSourceWithLogin() reads a profile's RTSP URI over ONVIF.
- Export vrek log (live video goal, decisions, codec finding).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-19 15:33:55 -05:00

19 lines
715 B
TypeScript

// Installs the pinned MediaMTX video bridge into ./bin (vrek dec-xkn4z0e). The download is
// checked against a SHA-256 committed in src/lib/mediamtx-install.ts before anything is
// written. Safe to re-run: an installed matching build is left alone.
//
// npm run video:install
import { installMediamtx } from "../src/lib/mediamtx-install.ts";
try {
const result = await installMediamtx();
console.log(
result.status === "installed"
? `Installed MediaMTX ${result.version} at ${result.binary} (checksum verified).`
: `MediaMTX ${result.version} is already installed at ${result.binary}.`,
);
} catch (err) {
console.error(err instanceof Error ? err.message : err);
process.exit(1);
}