This module implements the "rdk:component:camera"
API for real-time streaming protocol (RTSP) enabled cameras.
Four models are provided:
erh:viamrtsp:rtsp
- Codec agnostic. Will auto detect the codec of thertsp_address
.erh:viamrtsp:rtsp-h264
- Only supports the H264 codec.erh:viamrtsp:rtsp-h265
- Only supports the H265 codec.erh:viamrtsp:rtsp-mjpeg
- Only supports the M-JPEG codec.
Navigate to the CONFIGURE tab of your machine in the Viam app.
Add the camera component to your machine, searching for viamrtsp
and selecting your desired model.
Copy and paste the following attributes template into the resulting component's attribute panel:
{
"rtp_passthrough": true,
"rtsp_address": "rtsp://foo:bar@192.168.10.10:554/stream"
}
Edit the attributes as applicable.
The following attributes are available for all models of viamrtsp
cameras:
Name | Type | Inclusion | Description |
---|---|---|---|
rtsp_address |
string | Required | The RTSP address where the camera streams. |
rtp_passthrough |
bool | Optional | RTP passthrough mode (which improves video streaming efficiency) is supported with the H264 codec if this attribute is set to true . Default: false |
{
"components": [
{
"name": "your-rtsp-cam",
"namespace": "rdk",
"type": "camera",
"model": "erh:viamrtsp:rtsp",
"attributes": {
"rtp_passthrough": true,
"rtsp_address": "rtsp://foo:bar@192.168.10.10:554/stream"
}
}
],
"modules": [
{
"type": "registry",
"name": "erh_viamrtsp",
"module_id": "erh:viamrtsp",
"version": "latest"
}
]
}
Note
The above is a raw JSON configuration for an rtsp
model.
To use another provided model, change the "model" string.
To test your camera, go to the CONTROL tab of your machine in the Viam app and expand the camera's panel.
The binary is statically linked with FFmpeg v6.1, eliminating the need to install FFmpeg separately on target machines.
We support building this module using the Makefile for the following host/target combinations:
Host | Target | Supported |
---|---|---|
Linux/Arm64 | Linux/Arm64 | ✅ |
Linux/Arm64 | Android/Arm64 | ❌ |
Linux/Amd64 | Linux/Amd64 | ✅ |
Linux/Amd64 | Android/Arm64 | ✅ |
Darwin/Arm64 | Darwin/Arm64 | ✅ |
Darwin/Arm64 | Android/Arm64 | ✅ |
Darwin/Amd64 | Darwin/Amd64 | ❌ |
Darwin/Amd64 | Android/Arm64 | ❌ |
- Build for Linux targets:
- Install canon:
go install github.com/viamrobotics/canon@latest
- Startup canon dev container.
- Linux/Arm64:
canon -profile viam-rtsp-antique -arch arm64
- Linux/Amd64:
canon -profile viam-rtsp-antique -arch amd64
- Linux/Arm64:
- Build binary:
make
- Install canon:
- Build for MacOS target:
- Build binary:
make
- Build binary:
- Build for Android target:
- Cross-compile from Linux/Amd64 or Darwin/Arm64 host.
- To build from Linux/Amd64 host:
- Startup canon:
canon -profile viam-rtsp-antique -arch amd64
- Build binary:
TARGET_OS=android TARGET_ARCH=arm64 make
- Startup canon:
- To build from Darwin/Arm64 host:
- Build binary:
TARGET_OS=android TARGET_ARCH=arm64 make
- Build binary:
- Binary will be in
bin/<OS>-<CPU>/viamrtsp
- Clean up build artifacts:
make clean
- Clean up all files not tracked in git:
make clean-all
- Non fatal LibAV errors are suppressed unless the module is run in debug mode.
- Heavily cribbed from gortsplib examples: