> For the complete documentation index, see [llms.txt](https://docs.eyepop.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eyepop.ai/deploying/on-premise/streams.md). Agents can also search and read this documentation through its [MCP server](https://docs.eyepop.ai/~gitbook/mcp).

# Persistent Streams

Keep cameras, webcams and video files running on the instance, by name

A **persistent stream** is a source the instance runs on its own, by name: a network camera, a webcam plugged into the machine, a video at a url, or a video file played as if it were a camera. Once you start it, the instance keeps it running: it restarts it when it fails and starts it again when the machine or the container restarts, until you stop it. Each stream runs one pop on its source, and sends its results to the **outputs** it declares, such as a webhook: they are the only way to get a stream's results.

A stream runs here, on the instance's own hardware, or is **relayed**: the instance reads the source and uploads it to EyePop's cloud, which runs the pop. See [Relay to the Cloud](https://docs.eyepop.ai/deploying/on-premise/relay.md).

<figure><img src="https://1072321683-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FDoCvfjveqiJFmk0cnXCp%2Fuploads%2Fgit-blob-73cc238b1bc4f19a5e9956d7226d5623eb72b4a4%2Fstreams-overview.svg?alt=media" alt="Two separate flows. First, once: the EyePop CLI starts the stream on the EyePop on-premise instance with its pop and outputs, and gets back only that the stream started, no results. Second, continuously until you stop it: the camera sends video to the instance, which runs the pop there or relays it to EyePop&#x27;s cloud, and the results go, as they happen, to the webhook sink declared as the stream&#x27;s output with --output. The outputs are the only way to get a stream&#x27;s results."><figcaption><p>Starting a stream returns no results. The outputs the stream declares are the only way to get them. See <a href="#send-a-streams-results-to-a-webhook">Send a stream's results to a webhook</a>.</p></figcaption></figure>

## Before you start

Streams need the [EyePop CLI](https://docs.eyepop.ai/cli/getting-started.md) 0.28.0 or later (`eyepop --version`) and the instance's history database:

```bash
eyepop instance set --history on
```

See [`--history`](https://docs.eyepop.ai/deploying/on-premise/settings.md#history-history-retention-and-history-record-boot-pipeline). The instance must be running for the stream commands.

## Start a stream

Name the stream and its source. A network camera or a url:

```bash
eyepop instance stream start door --url rtsp://192.168.1.20:554/stream1
```

A webcam on this machine (Linux):

```bash
eyepop instance stream start desk --video-device /dev/video0
```

A video file on this machine, played in real time and started over when it ends, as a camera would:

```bash
eyepop instance stream start lobby --file ./lobby-recording.mp4
```

A device or a file has to be passed into the instance's container. The first stream that needs one recreates the container once, so every stream restarts; after that, a stream that reads the same device or file starts without a restart. The CLI keeps what it passes in, in `compose.streams.yaml` beside the instance's other files; `instance init` and `instance set` leave it alone.

The stream runs the pop the instance serves. To run another pop, give it with `--pop`, as a file or as JSON inline. This pop detects people and tracks each one across frames:

```json
{
  "components": [
    {
      "type": "inference",
      "ability": "eyepop.person:latest",
      "categoryName": "person",
      "forward": {
        "operator": { "type": "crop" },
        "targets": [
          { "type": "tracking", "reidModel": "eyepop.person.reid:latest" }
        ]
      }
    }
  ]
}
```

```bash
eyepop instance stream start door --url rtsp://192.168.1.20:554/stream1 --pop ./person-tracking.json
```

`--pop` also takes a saved pop's UUID, and `--ability <alias>` runs a single ability as a one-component pop. See [Pops](https://docs.eyepop.ai/platform/pop.md) for what a pop can do. A stream keeps the pop it was started with, even when the instance's own pop changes later. Starting a stream with a name that exists replaces it.

## Options

Every option of `eyepop instance stream start`; the [command reference](https://docs.eyepop.ai/cli/reference.md) has the same list from `--help`.

| Option                              | What it does                                                                                                                             |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `--url <URL>`                       | The source: an `rtsp://` or `rtsps://` camera, or an `http://` or `https://` url.                                                        |
| `--video-device <DEVICE>`           | The source: a video device on this machine, such as `/dev/video0` (Linux).                                                               |
| `--file <PATH>`                     | The source: a video file on this machine, played in real time and over again.                                                            |
| `--pop <POP>`                       | The pop the stream runs: a file, JSON inline, or a saved pop's UUID. Default: the instance's.                                            |
| `--ability <ALIAS>`                 | Runs one ability as the stream's pop, such as `eyepop.person:latest`.                                                                    |
| `--relay`                           | Relays the stream to EyePop's cloud, which runs its pop. See [Relay to the Cloud](https://docs.eyepop.ai/deploying/on-premise/relay.md). |
| `--relay-results <cloud\|instance>` | Where a relayed stream's results go. Default: `cloud`.                                                                                   |
| `--fps <FPS>`                       | Reads the source at that many frames per second, such as `5`, or `1/2` for one frame every two seconds.                                  |
| `--target-resolution <WxH>`         | Scales the video down to fit inside that box, such as `1280x720`, keeping its aspect ratio.                                              |
| `--motion`                          | Runs the pop only while something moves in the scene.                                                                                    |
| `--motion-sensitivity <0-1>`        | How small a change counts as motion in a cell (default `0.5`). Needs `--motion`.                                                         |
| `--motion-threshold <0-1>`          | The share of cells that must move for the scene to count as moving (default `0.01`). Needs `--motion`.                                   |
| `--motion-gap <SECONDS>`            | Seconds without motion after which the scene counts as still, 1 to 60 (default `1`). Needs `--motion`.                                   |
| `--motion-grid <XxY>`               | The motion grid's cells across and down, each 8 to 32 (default `10x10`). Needs `--motion`.                                               |
| `--output webhook=<url>...`         | Also sends the stream's results to a webhook. See below.                                                                                 |

A webcam that is mostly watching an empty room is a good fit for motion detection:

```bash
eyepop instance stream start desk --video-device /dev/video0 --fps 5 --motion --motion-gap 5
```

## Send a stream's results to a webhook

`--output` names a webhook that gets the stream's results as they happen:

```bash
eyepop instance stream start door --url rtsp://192.168.1.20:554/stream1 \
  --output webhook=https://hooks.example.com/eyepop
```

The webhook gets every event of the stream as a JSON request: each prediction (`prediction.made`), each selected prediction (`prediction.selected`), each change of the stream's status (`stream.status_changed`), and the instance's `track.started`, `track.ended`, `insight.completed` and `journey.matched`. `events=` limits it to the events it names, joined with `+`:

```bash
--output webhook=https://hooks.example.com/eyepop,events=prediction.tracked+stream.status_changed
```

A webhook that wants a credential names a header and the **environment variable** that holds its value. The value is never written on the command line, where your shell history would keep it:

```bash
export CRM_TOKEN='Bearer 7f3c...'
eyepop instance stream start door --url rtsp://192.168.1.20:554/stream1 \
  --output webhook=https://hooks.example.com/eyepop,header=Authorization:env:CRM_TOKEN
```

The CLI gives the instance the variable's value, and the stream's configuration holds only `${CRM_TOKEN}`, so the secret is not in it. Setting a new value and starting the stream again replaces it. `--output` can be given more than once.

A url may hold commas. One that holds `,header=` or `,events=` itself is kept whole by writing the options first and `webhook=<url>` last, such as `--output events=prediction.made,webhook=https://hooks.example.com/a,events=b`; with no options, write `--output ,webhook=<url>`.

The events, their delivery and the payload are the same as for any source's outputs; see [Outputs](https://docs.eyepop.ai/platform/outputs.md).

{% hint style="info" %}
A stream whose pop runs on the instance can deliver to a webhook on your own network, such as `http://10.0.0.5/hook`. A relayed stream whose results stay in the cloud (`--relay-results cloud`) is delivered by EyePop's cloud, which only sends to public addresses.
{% endhint %}

## See how they run

```bash
eyepop instance stream list
```

```
door  running
  source: rtsp://192.168.1.20:554/stream1
  relay:  -
  output: webhook https://hooks.example.com, 1482 delivered, 0 dropped
desk  running
  source: /dev/video0
  relay:  cloud, connected
  output: webhook https://hooks.example.com
lobby  stopped
  source: file:///media/streams/lobby/lobby-recording.mp4
  relay:  -
```

An output shows only its url's scheme and host, and how its deliveries go: `failing (<reason>)` when the webhook is not taking them. A relayed stream whose results stay in the cloud shows no counts: the cloud delivers them.

## Stop and start a stream

```bash
eyepop instance stream stop door
eyepop instance stream start door
```

Stopping keeps the stream's definition; starting it without a source runs it again as it was.

## Things to know

* Each start and stop restarts every stream of the instance from the new configuration.
* Two `stream start` commands on the same machine run one after the other: the second waits for the first.
* When something else changes the instance's streams while a start or stop runs, such as another `stream start` or a save in the dashboard, the command saves nothing and asks you to run it again, rather than undo that change.
* A camera's password in a url is stored in the instance's configuration as you give it.
* `eyepop instance delete` removes the files the CLI wrote for streams, including the one holding output secrets.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.eyepop.ai/deploying/on-premise/streams.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
