Reeve Docs

Docs / Sidecars

Media plane

An operator may deploy one shared media server (MediaMTX) for the whole installation. A plugin tells Reeve where the server may pull one of its cameras from, either an address the server can dial or a negotiation the host holds. The plugin does nothing else: the host registers the path over the plane's control API, posts the viewer's offer to the plane and relays the answer back.

The plane is off by default (Cameras:MediaPlane). A camera the plane cannot take keeps the transport it already had. For deployment and settings see the media plane operator guide.

Access and topology

Both of the plane's APIs are reachable only from the backend, and the viewer is never told the plane exists. The control API accepts arbitrary source addresses and returns a camera's own password when read, so a plugin that could reach it could point a camera at anything. The APIs sit on a Service no ingress reaches, behind an account only the backend holds, and behind a network policy naming the backend's pods when the chart's policies are on. A plugin granted the plane's host could still dial a ClusterIP, which is a LAN address, and the account is what stops it.

UDP and TCP media share one port number, so the ports a firewall must name do not grow with cameras or viewers. The port published outside must equal the port the plane listens on: a rewritten external port leaves every session in ICE checking with no error on either side.

The plane runs as exactly one replica, because sessions live in its memory and a second replica would answer half the checks for sessions it does not hold. Changing an announced address terminates every session on the plane. Adding and removing camera paths costs nothing.

When a camera uses the plane

A camera is served by the plane when its plugin declares a plane ingest. The plugin decides, because only it knows whether its own peering is reachable, and its own workload is the fallback. A plugin that declares no ingest never reaches the plane. The plane reads the camera once and fans that pull out to the browser, the phone and the Matter bridge. This matters because the reference hardware allocates one encoder, so a second reader of the device would get a black tile.

Every case in which the plane has no answer falls back to the transport the camera already had: no plane deployed, no ingest declared, a plane or remux that would not take the camera. A plugin cannot see whether a plane is deployed, which is why the choice lives in the host. When any hop refuses, Reeve offers no origin at all rather than a URL that would fail. That covers a plane that will not take the registration, a remux that will not take the stream or stops answering, and a half-configured deployment (including an address configured without a scheme). The surfaces that list transports read a declared path as a camera that streams, so a failing URL must never be offered.

Calls to the plane and the remux return a result instead of throwing, and an unanswered question is distinct from zero. Viewer and reader counts are null when unanswered, so a credential outage does not look like an unwatched plane. A failed read leaves the camera on the transport it had. The control and remux clients have a finite timeout, so a hung plane costs a camera its registration and never ties up a request thread. The remux timeout is one step above the plane's read timeout.

Only the replica holding a camera's plugin declares its plane ingest and registers the path. Every replica reads what was registered, because the plane and the remux are configured addresses all replicas share. A replica with no ingest address of its own does not register, because it would point the plane at a backend that cannot negotiate.

Registration happens when a viewer asks for transports

For a plane-backed camera, resolving the origin in stream-info creates the plane path and the remux stream. That is three in-cluster round trips, paid only by cameras whose plugin declares a plane ingest. Registering first keeps the answer honest, since advertising a path and registering it later would advertise a transport that fails on first use. Nothing is dialled by registration: on-demand paths and the remux wait for a consumer, so no encoder is allocated until a viewer arrives.

Timeouts

Cameras:MediaPlane:PlaneReadTimeout (chart value cameras.mediaPlane.readTimeout, Compose variable CAMERAS_MEDIA_PLANE_READ_TIMEOUT_SECONDS) defaults to 14 seconds. The other waits derive from it. The backend's ingest budget (12 s) and WHEP wait (16 s) sit one step of 2 seconds either side of it. The plane's own readTimeout, webrtcHandshakeTimeout and pathDefaults.sourceOnDemandStartTimeout are rendered from it, as MTX_READTIMEOUT, MTX_WEBRTCHANDSHAKETIMEOUT and MTX_PATHDEFAULTS_SOURCEONDEMANDSTARTTIMEOUT in Compose. A change restarts the plane and applies to every path it holds. An operator with a mediamtx.yml of their own mirrors the value into those three keys.

The default is 14 seconds because a Matter camera with no route to the internet waits about ten seconds on its built-in STUN server before it answers with host candidates only, and a home camera without internet is an ordinary configuration. The chart refuses a value outside 10 s to 16 s so the longest wait stays inside the viewer's 20-second window. The backend does not check the value, so a Compose or own-config installation keeps it in that range itself. The full budget table is in camera WebRTC signalling.

The per-path sourceOnDemandStartTimeout defaults to 10 s in MediaMTX and ends a waiting viewer and the source with it, whatever readTimeout is. That is why it is rendered from the same value. These settings stay at their defaults: sourceOnDemandCloseAfter (which runs only after the last reader leaves), the per-path whepHandshakeTimeout, whepSTUNGatherTimeout and whepTrackGatherTimeout, and the global writeTimeout. trackGatherTimeout and stunGatherTimeout have their own chart values, and the backend's PathReadyWait and IngestCandidateGrace are separate options.

cameras.mediaPlane.trackGatherTimeout is not part of this chain. It is the time a publisher has to produce a first frame, and raising it does not change what a viewer waits.

A plane that stays quiet past the viewer's window is not recovered: the socket closes and the request is cancelled. An installation with no plane never reaches any of this.

STUN

With cameras.mediaPlane.stunUrls (Compose: the webrtcICEServers2 block in mediamtx.yml) the plane gathers a server-reflexive address from public STUN servers, bounded by webrtcSTUNGatherTimeout (2 s), and puts it in its answer. Only stun: entries are accepted, and the plane never holds a credential. The gather wait applies to every answer, LAN viewers included. Ingest is unaffected, because the plane's WHEP client takes its ICE servers from the target.

The viewer-side list is the separate backend setting Cameras:MediaPlane:ViewerStunUrls. Plane STUN does not enable viewer STUN. Operators choose STUN, a public port, or both; see viewers outside the home.

The ingest credential

For a camera the plane cannot dial, the plane pulls from the backend over WHEP. It presents a credential derived per camera path from one configured secret (IngestSecret), and the backend compares it in constant time. Any replica can compute it, a leaked credential opens that one camera only, and without the secret no ingest is served. Matter media tickets work the same way; see Matter bridge cameras.

The fMP4 transport and the remux

A camera that the plane pulls and no workload proxies has exactly one transport on its own, WebRTC, which is all a Matter camera negotiates. A browser that cannot reach the plane over UDP or ICE-TCP would show a dark tile, and so would the phone, whose picture is a WebView on the same preview and has no WebRTC stack. The fMP4 transport covers those viewers.

The remux

A go2rtc remux runs as a second container in the plane's own pod and reads the plane over RTSP on loopback. The RTSP listener is bound to loopback and reaches no Service. The backend registers the camera's plane path on the remux over an API port on the plane's ClusterIP Service and gets back an origin naming /api/stream.mp4 and /api/frame.jpeg under it. The plane and the remux scale and restart together. Compose uses the same shape with network_mode: "service:media-plane", so RtspAddress is the same loopback address in both modes.

The remux reads anonymously and its source carries no credential. The plane authenticates RTSP against the same account as its control API, and go2rtc keeps every registered source verbatim in a stream table its API serves back, so giving the remux the plane's password would publish it. The plane instead has one anonymous reader limited to 127.0.0.1/32 and to read, which only the container sharing its network namespace can be. An RtspAddress configured with a userinfo part leaves the remux unconfigured.

Passing through or re-encoding

Before registering a camera on the remux, the backend reads the plane's runtime path endpoint (v3/paths/get/<path>, whose tracks2 carries codec, profile and resolution). The configuration endpoint cannot answer this, because a path can be configured and carry nothing. A camera sending H.264 is passed through untouched. Only a camera whose codec the consumers cannot decode is re-encoded, and only to H.264, because H.265 out of the remux is hvc1, which Chrome and Firefox do not play through MSE. If transcoding is off and the camera cannot be repackaged as it is, the fMP4 transport is not offered.

The plane describes only a path something is reading, and the backend resolves before anyone reads, so on a cold camera the plane says nothing. The backend therefore remembers each camera's last seen codec, per replica, in memory. A live answer always replaces the remembered one, and the memory is used only when the plane is silent. The first viewer of a camera a replica has never seen gets a pass-through, and a restart forgets everything.

Hardware encoding

With no card bound, the backend still re-encodes a camera the consumers cannot decode, in software on the remux's CPU budget. Hardware is requested only where the deployment bound a card (Cameras__MediaPlane__EncoderHardware, which the chart sets under the same condition that renders the encoder entry). The two must agree. go2rtc accepts a source naming a device its configuration has no ffmpeg: entry for, so a mismatch publishes a URL whose ffmpeg fails for every reader, with a dark tile and nothing in the backend log.

Binding a card takes two separate settings in the chart:

  1. The device reaches the container and can be opened there. gpu.hostPath.enabled bind-mounts it and requires privileged: true, which lifts the device-cgroup denial a hostPath character device otherwise meets (EPERM, which ffmpeg reports as No VA display found, the same message as having no device). The pod runs as UID 1000 and needs the render group for the node's root:render 660 render node. A cluster with a device plugin instead requests the advertised resource in remux.resources.limits, which grants cgroup access and schedules the pod on a node with a card. The chart passes those limits through unchanged.
  2. The encoder is told the card is there. gpu.enabled sets EncoderHardware and seeds go2rtc's ffmpeg: entry. gpu.encoder names what go2rtc is asked for. vaapi is the default and the only one the chart can seed. Any other encoder (cuda, qsv, v4l2m2m) needs its own gpu.ffmpeg entries.

Every part is required, because a missing one looks the same at runtime as having no card: a healthy pod that encodes in software. The chart refuses to render, naming the value, for gpu.enabled with neither a mount nor an extended resource, a mount without privilege, a mount without a render GID, a mount wired to no encoder, and an encoder it cannot seed with no entry supplied.

The seed names the device in an ffmpeg: entry (-init_hw_device vaapi=va:<path> -filter_hw_device va -c:v h264_vaapi), because go2rtc's own #hardware flags insert hwupload without a device reference and ffmpeg refuses them. An ffmpeg: source publishes back through go2rtc's own RTSP listener, so that listener is bound to 127.0.0.1 on a port of its own, published by no Service and declared as no container port. The port must differ from the plane's, because the two share one network namespace and a clash stops one of them from starting.

go2rtc behaviour to know

What follows holds for the pinned go2rtc image.

  • It writes every registered stream back into the config file it loaded. A read-only mount therefore answers 400 to a registration it has already applied. The chart copies the seed into an emptyDir (a tmpfs owned by the container's UID in Compose), and the backend reads the stream table back instead of trusting the status code. A restart starts with no streams, and the backend registers one per camera when a viewer asks.
  • Seeding streams as an empty flow mapping breaks its YAML writer, and every write then fails with yaml: line N: did not find expected key. The seed carries no such key.
  • It enforces api.username and api.password for callers outside loopback, but the chart and Compose configure none and the backend has no setting for one, and its API dials any address a caller names. Reachability is the whole of its access control, which is why it sits in the plane's pod, on the plane's Service and behind the plane's network policy rule for the backend.

The plane's Compose service has no healthcheck, because the image is a static binary on an empty base with no shell, so a CMD-SHELL probe can only fail.

A deleted camera leaves its remux stream behind. The plane path sweep does not reach the remux's table. The leftover entry has an idle producer that dials nothing and is cleared by a restart, because the config lives in an emptyDir. The growth is bounded by the number of cameras an installation has ever had.

Plane paths

Naming

A camera's plane path name is a prefix plus a hash of the plugin's source id, so a restart addresses the same paths and arbitrary device ids become safe path segments. Names cannot be reversed, so the backend builds its directory forward from every source. The prefix marks a path as this backend's, so the sweep never touches the plane's own all_others or an operator's hand-written paths. Two devices that produce the same name share one path, and the last writer wins.

Readiness and the hold

An on-demand path is dialled when a viewer arrives and dropped when the last one leaves. On the pinned image it answers ready: false with tracks2: [] whether the camera is fine or unreachable, readyTime is forgotten when the last reader goes, and online is true even for an address nothing answers on. It carries no liveness.

A path the plane dials itself (rtsp/rtsps) is held open (sourceOnDemand: false), and its ready is then accurate with nobody watching. That costs nothing new for an RTSP camera whose plugin workload already holds it around the clock. A camera the host negotiates for stays on demand, because the reference hardware allocates one encoder and holding it would spend the camera's only stream on nobody. The wanted hold can be computed by every replica: a path is held open when the plane dials the camera itself and either live transport is on. The sweeping replica reads the kind from the path's source scheme (rtsp/rtsps against whep/wheps) and nothing else from that field, which carries the camera's credentialed address.

A held path dials its camera the moment it is created, and MediaMTX answers a reader that arrives first with "no stream is available on path", where an on-demand path would hold that reader. So registration, and a replica's read of a path another replica registered, return for a held path only once the runtime endpoint says ready, for at most PathReadyWait (default 4 s, at most 8 s). A path that does not come up is handed over as it is, and that replica does not wait for it again for 30 seconds unless it adds the path anew. A camera that is down therefore costs one wait per replica rather than one per snapshot frame. On-demand paths are not waited for. Routes that resolve an origin without reading the plane (stream-info, the slot probe, event media links) pay the wait too, once per cooldown per replica for a camera that is down.

A sourceOnDemand patch answers 200 but makes the server reload and close the path in both directions, and deleting and re-adding the path is no better. The sweep therefore patches only a path that reports no reader, with the reader count re-read for that path immediately before the patch. A plane that does not answer reads as unknown, never idle. A window of one round trip remains, because the API has no compare-and-set, and losing it costs one viewer a reconnect. Registration never changes the hold, or the second viewer of a path would cut the first.

The sweep

The sweep runs hourly on the one replica that owns it, and sooner when transport switches change. A switch made on another replica reaches the owner over the cluster bus. The sweep reads the plane before the cameras, so a camera that appears in between owns any path it finds. A database read failure abandons the sweep. A pass that left a path alone because a viewer was reading it retries a minute later rather than an hour later, since nothing signals a reader leaving.

Refused registrations

Every viewer resolves the camera again, so the host reads a path before adding it (adding a held path is refused with 400). A 400 for a path the plane still does not hold afterwards is a verdict on that body, and the same body is not sent again for 30 seconds, doubling per pause up to 15 minutes. A changed address or credential is a different body and is sent at once. A 401, 404, 429, 5xx or no answer concerns the channel and pauses nothing. The pause lives in replica memory, so a restart clears it.

Operator switches

Integrations → Media Plane has switches for WebRTC, fMP4 and transcoding, plus Force re-encoding. They narrow what the deployment rendered for the whole household, and they are not a second place to deploy from.

The effective setting is the deployment AND the switch, so a switch can only narrow what the deployment provides. Every serving path (the WebRTC opener, the fMP4 origin resolver, its transcoding branch and the transport-obstacle reporter) uses the effective value. Only the operator page also shows the stored value beside the deployment. A transport the chart never rendered is never treated as available.

The write endpoint stores the three booleans as given and refuses nothing. Validating against the deployment, which each replica caches for thirty seconds, would give different verdicts on different replicas. A transport stored as on for a part nothing rendered has no effect until that part is deployed. Saving returns the recomputed status, showing what the deployment narrowed the request to.

A switch stops the next viewer and never the current one. stream-info stops advertising the transport and webrtc.ws answers 404 for a camera the plane was carrying, while open sessions run to their end. A switch deletes no plane path and no remux stream, so turning a transport back on serves the next viewer without a restart. The sweep releases the camera behind each path once neither live transport reads it.

Force re-encoding depends on transcoding: it is effective only when transcoding is also on, because forcing alone would drop the transport for cameras that were fine. Where every camera sends H.264 the re-encode branch is never taken, so without Force re-encoding a bound card cannot be told from a broken one. The page states the cost (one encode per camera) before the switch moves.

Every media-plane administration call checks cameras.media.view before contacting the plane, so an unauthorised caller cannot probe it. Changing a switch takes cameras.media.manage. Status probes the plane and the remux concurrently, so a down plane costs one connect timeout. A refresh re-probes, and opening the page alone never does. The remux's encoder probe doubles as its reachability check and reads a cache that keeps the last real answer for five minutes, so a page load never runs ffmpeg per codec and accelerator on the media pod, and a briefly unreachable remux does not pin "no encoder". Required-settings lists appear only once the plane is up, and a forced-transcode request that cannot happen names the remux only when transcoding is enabled.

See also

  • Media plane operator guide: deploying it, reaching it from outside the home, and every setting.
  • Camera media: the camera media proxy, viewer slots and the transports.
  • Camera WebRTC signalling: the negotiation the host relays, including the case where the plane is the viewer's peer.
  • Matter bridge: the bridge reads a camera the plane carries through the backend's media endpoint, like any other viewer. Which Matter camera type it composes does not depend on the plane.