Camera Streaming with go2rtc
Introduction
Section titled “Introduction”go2rtc is a lightweight camera streaming application that can expose a printer camera through WebRTC. For printer monitoring, this can provide a lower-latency stream than a traditional MJPEG setup while still integrating cleanly with browser-based printer UIs.
This guide installs go2rtc on a Raspberry Pi OS based printer host, configures a USB camera stream named chamber, starts go2rtc automatically with systemd, and adds the stream to Mainsail and Fluidd.
By the end, you will have:
- A
go2rtcbinary installed at/home/pi/go2rtc/go2rtc - A
go2rtc.yamlconfiguration file defining achambercamera stream - A
go2rtcsystemd service that starts on boot - A camera entry in Mainsail or Fluidd
Prerequisites
Section titled “Prerequisites”- A printer host running Raspberry Pi OS Bookworm or Trixie
- SSH access to the printer host
- A USB camera available as a Linux video device, usually
/dev/video0 - A recent Mainsail or Fluidd installation
- Browser access to the printer host on the same local network
Install FFmpeg
Section titled “Install FFmpeg”The example stream uses go2rtc’s FFmpeg source to read the USB camera and produce an H.264 WebRTC-compatible stream. Install FFmpeg before configuring go2rtc.
-
Update the APT package index:
Updating package indexes sudo apt update -
Install FFmpeg:
Installing FFmpeg sudo apt install -y ffmpeg -
Verify that FFmpeg is available:
Checking FFmpeg ffmpeg -versionThe command should print the installed FFmpeg version and build configuration.
Install go2rtc
Section titled “Install go2rtc”Install the go2rtc binary in /home/pi/go2rtc. The commands below use the go2rtc_linux_arm64 release asset, which is the correct binary for 64-bit Raspberry Pi OS.
-
Create the installation directory:
Creating the go2rtc directory mkdir -p ~/go2rtccd ~/go2rtc -
Download the latest go2rtc binary and save it as
go2rtc:Downloading go2rtc wget -O go2rtc https://github.com/AlexxIT/go2rtc/releases/latest/download/go2rtc_linux_arm64 -
Make the binary executable:
Making go2rtc executable chmod a+x go2rtc -
Verify the binary exists and is executable:
Checking the go2rtc binary ls -l /home/pi/go2rtc/go2rtcThe permissions should include executable bits, such as
-rwxr-xr-x.
Find Your Camera Device
Section titled “Find Your Camera Device”Before writing the go2rtc stream configuration, identify the Linux video device for your camera and confirm one supported capture mode.
-
List video devices:
Listing video devices ls -l /dev/video*A single USB camera is often
/dev/video0, but the number can vary. -
Install the V4L2 utilities:
Installing V4L2 utilities sudo apt install -y v4l-utils -
Map video devices to physical cameras:
Listing V4L2 devices v4l2-ctl --list-devicesUse this output to choose the correct
video=path forgo2rtc.yaml. If multiple cameras are connected,/dev/video0can change after reboot or after reconnecting USB devices. Stable multi-camera naming with persistent device paths or udev rules is outside the scope of this guide. -
List the selected camera’s supported formats and resolutions:
Listing camera modes ffmpeg -f v4l2 -list_formats all -i /dev/video0If your camera is not
/dev/video0, replace/dev/video0with the device path from the previous step. Use one reported format and resolution forinput_formatandvideo_sizeingo2rtc.yaml.
Configure a Camera Stream
Section titled “Configure a Camera Stream”Create /home/pi/go2rtc/go2rtc.yaml with a stream named chamber.
-
Open the configuration file:
Creating go2rtc.yaml nano /home/pi/go2rtc/go2rtc.yaml -
Add the following configuration:
go2rtc.yaml api:listen: ":1984"origin: "*"ffmpeg:bin: "ffmpeg"log:format: "color"level: "info"output: "stdout"time: "UNIXMS"rtsp:listen: ":8554"default_query: "video&audio"srtp:listen: ":8443"webrtc:listen: ":8555/tcp"streams:chamber: ffmpeg:device?video=/dev/video0&input_format=yuyv422&video_size=1280x720#video=h264#hardware
The chamber stream reads /dev/video0 as a V4L2 camera, requests yuyv422 input at 1280x720, and asks FFmpeg/go2rtc to produce H.264 video. The chamber stream name is used later in go2rtc, Mainsail, and Fluidd.
Test go2rtc
Section titled “Test go2rtc”Before creating the systemd service, run go2rtc in the foreground so configuration errors are visible immediately.
-
Start go2rtc manually:
Starting go2rtc manually /home/pi/go2rtc/go2rtc -config /home/pi/go2rtc/go2rtc.yaml -
Open the go2rtc WebUI in a browser:
go2rtc WebUI http://<printer-ip>:1984 -
Select the
chamberstream link.
The video should start after a short delay. Stop the foreground process with CTRL-C before continuing.
Common errors at this stage:
permission denied: the binary is not executable, or the camera device permissions are wrong.no such file or directory: the binary path, config path, or camera path is wrong.- FFmpeg format errors:
input_formatorvideo_sizeis not supported by the camera. - Hardware encoder errors: remove
#hardwarefrom the stream line and test again.
Start go2rtc on Boot
Section titled “Start go2rtc on Boot”Create a systemd service so go2rtc starts automatically when the printer host boots.
-
Create the service file:
Creating the go2rtc service nano /home/pi/go2rtc/go2rtc.service -
Add this unit:
go2rtc.service [Unit]Description=go2rtcAfter=network.target[Service]Type=simpleWorkingDirectory=/home/pi/go2rtcExecStart=/home/pi/go2rtc/go2rtc -config /home/pi/go2rtc/go2rtc.yamlExecReload=/bin/kill -HUP $MAINPIDRestart=alwaysRestartSec=5User=rootGroup=rootEnvironment=PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin[Install]WantedBy=multi-user.target
-
Enable the service using the absolute service-file path:
Enabling go2rtc sudo systemctl enable /home/pi/go2rtc/go2rtc.service -
Reload systemd and start go2rtc:
Starting go2rtc sudo systemctl daemon-reloadsudo systemctl start go2rtc -
Check the service state:
Checking go2rtc service state sudo systemctl status go2rtc
To follow service logs while troubleshooting, run:
sudo journalctl -u go2rtc -fConfigure Mainsail
Section titled “Configure Mainsail”Mainsail includes a WebRTC (go2rtc) webcam service for go2rtc streams.
-
Open Mainsail in your browser.
-
Go to Settings > Webcams.
-
Add a new webcam entry.
-
Configure the webcam with these values:
- Name:
Chamber - Service:
WebRTC (go2rtc) - Stream URL:
http://<printer-ip>:1984/stream.html?src=chamber&mode=webrtc - Aspect ratio:
16:9for the sample1280x720stream - Rotation/flip: Set these to match your camera orientation
- Name:
The src=chamber parameter must match the stream name in go2rtc.yaml.
Configure Fluidd
Section titled “Configure Fluidd”Fluidd includes a native WebRTC (go2rtc) camera type.
-
Open Fluidd in your browser.
-
Go to Settings > Cameras.
-
Add a new camera.
-
Configure the camera with these values:
- Name:
Chamber - Type:
WebRTC (go2rtc) - go2rtc URL:
http://<printer-ip>:1984 - Stream name/source:
chamber - Aspect ratio:
16:9for the sample1280x720stream - Rotation/flip: Set these to match your camera orientation
- Name:
Fluidd field labels may vary by version. The required values are the go2rtc WebUI URL and the chamber stream name.
Troubleshooting
Section titled “Troubleshooting”Check go2rtc Service State
Section titled “Check go2rtc Service State”Use systemd to confirm whether go2rtc is running:
sudo systemctl status go2rtcIf the service is not active, inspect the logs:
sudo journalctl -u go2rtc -fConfirm the Camera Device Path
Section titled “Confirm the Camera Device Path”List available video devices:
ls -l /dev/video*If your camera is not /dev/video0, update the video= parameter in go2rtc.yaml.
Confirm the Camera Format and Resolution
Section titled “Confirm the Camera Format and Resolution”List supported camera modes:
ffmpeg -f v4l2 -list_formats all -i /dev/video0If the configured input_format or video_size is not listed, update the stream line to use a supported mode.
Check for Another Process Using the Camera
Section titled “Check for Another Process Using the Camera”Check whether another service already has the camera open:
sudo fuser /dev/video0If another process is listed, stop or reconfigure that service before starting go2rtc with the same device.
Remove Hardware Encoding
Section titled “Remove Hardware Encoding”If go2rtc starts but the stream fails, or FFmpeg reports hardware encoder errors, remove #hardware from the stream line and restart go2rtc:
streams: chamber: ffmpeg:device?video=/dev/video0&input_format=yuyv422&video_size=1280x720#video=h264Then restart the service:
sudo systemctl restart go2rtcCheck Browser and Network Access
Section titled “Check Browser and Network Access”Open the go2rtc WebUI directly:
http://<printer-ip>:1984If the WebUI does not load, confirm the printer host IP address and check that your browser is on the same local network.