Build pages › Streams and live video
Docs › Build pages › Streams and live video

Streams and live video

A stream is a named value, like lab/my-box, that a remote server (or a script, a sensor, a webhook) sends twice a second. Every open copy of a space that declares it draws each value about a tenth of a second later, and the space's buttons can send presses back. The space is never republished. Sending needs Max; anyone who can open the space can watch. See it work, with an interactive example.

Hook up a server (Linux or Mac, Node 20+). From a computer signed in to spacesheep, give the server a key that can only send numbers, then start the stream on it:

npx -y spacesheep@latest keys create --scope stream --name my-box | ssh my-box 'npx -y spacesheep@latest keys save'
npx -y spacesheep@latest stream lab/my-box --system --load-test --service

--system reads the server's own numbers (per-core load, memory, temperatures), --load-test adds Run test / one core / memory / stop buttons, and --service keeps it running in the background. For your own readings, use --run "your-program": each JSON line it prints is one value. A space reads a stream only if its page declares it: <meta name="ss-streams" content="lab/my-box">, then ss.stream("lab/my-box").draw(…). Anyone who can open the page can press its buttons; add data-press="editors" to the declaration and only people who can edit it can (everyone else's press is refused, and the page can grey the button out). Agents get all of this from the skill and the MCP tool streams.

When a space isn't streaming, /me/streams shows where it stops: whether each server is sending (its last hour minute by minute, and any value that was refused and why), who has a page open that reads it, and whether that page drew what it got. Agents read the same thing with streams and health: true.

Live video

Stream a camera (a phone, a webcam, a screen, an IP camera) into a space in three steps:

  1. Publish a page that names the camera and plays it:
    <meta name="ss-streams" content="lab/cam-1">
    <video data-ss-stream="lab/cam-1" style="width:100%"></video>
  2. Open https://spacesheep.dev/film/lab/cam-1 on your phone or computer and press Go live (camera, screen or a test pattern). The player on the page shows a Film here button with a code to scan, too.
  3. Or from a terminal or a server, with ffmpeg: npx -y github:spacesheep-dev/spacesheep-cli stream lab/cam-1 --camera (or --screen, --rtsp <url>, --file <video>).

The page's owner and anyone who can edit it can film; filming is part of Max. Only signed-in people who can open the page watch, so for a public broadcast use YouTube. Viewers get live video, or 3 pictures a second when live video isn't available to them. Nothing is recorded.

Find people in the video. Only when you ask for it: name two more streams beside the camera, and the phone or computer that films it finds people and faces itself (nothing runs on a server) and logs each person who arrives with a small photo.

<meta name="ss-streams" content="lab/cam-1, lab/cam-1/detections, lab/cam-1/arrivals">
<video data-ss-stream="lab/cam-1" data-ss-detect style="width:100%"></video>
<script>
ss.stream("lab/cam-1/detections").draw((v) => v && v.count);             // { count, people, faces }: boxes, named once known
ss.video.arrivals("lab/cam-1").then((r) => r.arrivals);                // { id, at, name, sure, by, photo }, newest first
ss.stream("lab/cam-1/arrivals").on((a) => { /* a new arrival, or a name given */ });
ss.video.name("lab/cam-1", id, "Ana");                                    // owner and editors: who it was
</script>

data-ss-detect draws the boxes over the video. Once someone has been named, the camera owner's AI model compares each new arrival with the named photos and names it when it can. Photos are kept 30 days and only people who can open the page see them.

Was this page helpful?