Stream basics
Streams are configured per device and use the MediaMTX server to handle video ingestion and distribution.Stream properties
Each device stream has the following properties:- Stream name: Unique identifier for the stream (typically matches device name)
- Source URL: The RTSP or other protocol URL from the device
- Active slot: Which connection slot (primary/secondary) is currently active
- Ready status: Whether the stream is currently receiving data
Configuring a stream
Configure device connection
Set up the device’s host and connection details in the device configuration. The host determines where the stream will be pulled from.
Configure stream URL template
The stream URL is automatically constructed from device properties. You can customize the URL template in PocketBase hooks to match your device’s stream format.Common formats:
- RTSP:
rtsp://{{host}}:{{port}}/stream - HTTP:
http://{{host}}:{{port}}/mjpeg - WebRTC:
webrtc://{{host}}:{{port}}/stream
Stream modes
Devices can operate in different streaming modes:Recording mode
Continuous recording of the stream to disk:Live streaming mode
Live streaming without recording:Dual slot streaming
For devices with dual connection slots, streams can automatically failover between connections.Configure dual slots
Set up both primary and secondary connection slots in the device configuration with different hosts.
Enable automatic switching
Enable
autoSlotSwitch in the device configuration to allow automatic failover.Stream URL updates
When the active slot changes, PocketBase hooks automatically update the stream URL in MediaMTX to point to the new host.The system:
- Detects
activeSlotfield changes - Constructs new stream URL using the active slot’s host
- Updates MediaMTX configuration
- Sends notifications about the slot change
Accessing streams
HTTP Live Streaming (HLS)
Access HLS streams for web playback:WebRTC
Access WebRTC streams for low-latency playback:RTSP
Access raw RTSP stream:Low-Latency HLS (LL-HLS)
For ultra-low latency streaming:Stream status monitoring
Check stream health
Query MediaMTX API to check stream status:Monitor all streams
List all active streams:Stream automation with Baker
The Baker service can automatically toggle streams on and off based on schedules.Time-based streaming
Configure a device to stream only during specific hours:Duration-based streaming
Configure periodic streaming cycles:Performance optimization
Bandwidth management
Optimize stream quality based on network conditions: High quality (for local networks):Connection pooling
MediaMTX automatically manages connection pooling. Configure limits inmediamtx.yml:
Troubleshooting
Stream not appearing
-
Verify device is configured with correct host:
-
Check MediaMTX can reach the device:
-
Check MediaMTX logs:
Stream stops unexpectedly
-
Check device health:
- Verify network connectivity between MediaMTX and device
-
Check for slot switching events in Switcher logs:
High latency
- Use WebRTC instead of HLS for lower latency
-
Reduce buffering in MediaMTX configuration:
- Check network conditions between viewer and MediaMTX
- Consider using LL-HLS for a balance between compatibility and latency