5 Commits
Author SHA1 Message Date
ryan.mcgeeandClaude Opus 4.7 2250cdd0ec Support hosting at a URL sub-path via OCTOCAM_BASE_PATH
When OCTOCAM_BASE_PATH is set (e.g. /octocam), all routes are served
under that prefix and the bare prefix without trailing slash gets a
301 redirect to the canonical form with trailing slash.

Implementation:
- Config: OCTOCAM_BASE_PATH env var, normalized to ensure leading
  slash and stripped trailing slash
- Server: when base path is set, wrap the existing mux with
  http.StripPrefix and add a redirect handler for the bare prefix.
  All internal routes stay registered at their root paths so the same
  mux works whether the prefix is empty or not.
- Templates: index.html and feed.html receive a BasePath template
  variable used to construct all asset, stream, link, and JS fetch
  URLs. Standalone /raw and /overlay pages prefix StreamURL and
  OtherURL in server.go before rendering.
- Redirect from /overlay (when overlay disabled) now goes to
  BasePath + "/" instead of "/"

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-13 14:52:12 -05:00
ryan.mcgeeandClaude Opus 4.7 881bb2943e Persist RTSP feed state across reboots; default both feeds off
RTSP feeds now default to disabled on first run. Enabled/disabled state
is saved to /var/lib/octocam/feeds.json on every toggle and restored at
startup, so the last-known state survives service restarts and reboots.

install.sh creates /var/lib/octocam owned by the octocam user. Config
adds OCTOCAM_STATE_FILE with the same default path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-11 17:18:50 -05:00
ryan.mcgeeandClaude Sonnet 4.6 e1acfb90ed Update README, install script, and env example
README: rewrite streams/pages table to reflect MJPEG HTTP browser
streams and individual feed pages; update architecture diagram; add
API reference table; broaden install instructions to cover any arm64
SBC (Rock64, Pi, etc.); document all config variables.

install.sh: auto-detect MediaMTX download arch from uname -m (was
hardcoded to arm64v8); add dnf support; clean up trap for temp dir;
print RTSP URLs at the end of install; remove Pi-specific wording.

.env.example: remove unused HLS/WebRTC vars; clean up comments.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:59:38 -05:00
ryan.mcgeeandClaude Sonnet 4.6 4adf3a5c2f Switch browser to MJPEG HTTP, reduce CPU, fix live feeds
Browser: replace WebRTC/HLS with direct MJPEG HTTP streams
(/stream/raw, /stream/overlay) served by the Go server itself.
<img> tag, no JavaScript, works in every browser, zero extra encoding.

CPU:
- Raw RTSP now uses ffmpeg -c:v copy (MJPEG passthrough), eliminating
  one full libx264 encode pass.
- Overlay RTSP throttled to 5fps (OCTOCAM_OVERLAY_RTSP_FPS); browser
  still receives the full camera framerate via MJPEG HTTP.

Architecture: new internal/mjpeg.Broadcaster fans JPEG frames out to
any number of HTTP clients with per-client drop-on-full buffering.
RTSP URLs shown in the stats bar for VLC / OctoPrint use.

Fix .gitignore to use /octocam so it doesn't match cmd/octocam dir.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 16:43:43 -05:00
ryan.mcgeeandClaude Sonnet 4.6 7d155d5b13 Initial implementation of OctoCam
Go service that reads a USB webcam via V4L2, overlays OctoPrint stats
(state, filename, temps, progress, ETA) on one stream, and publishes
both raw and overlay feeds to MediaMTX via RTSP for WebRTC/HLS/RTSP
fan-out. Includes web UI, systemd units, and installer script.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-11 15:48:09 -05:00