pi-webrtc
Raspberry Pi 與 Jetson 上那支常駐程式的設定、相機後端、信令、錄影與編譯說明。
Getting Started
Install pi-webrtc and see live video in your browser. It takes about 10 minutes. You only need the device, a camera, and a computer on the same network.
Raspberry Pi
Set up pi-webrtc on a Raspberry Pi and watch the camera in your browser. This guide uses WHEP, so you do not need any server.
NVIDIA Jetson
Set up pi-webrtc on an NVIDIA Jetson and watch the camera in your browser. This guide uses WHEP, so you do not need any server.
Troubleshooting
Fixes for the most common problems. If you are still stuck, open an issue. Include the full command, the log, and your device and OS versions.
Video & Audio
pi-webrtc reads video from a camera or a stream, encodes it, and sends it over WebRTC. This section shows which video sources you can use, how encoding works...
CSI Cameras
A CSI camera connects to the board with a ribbon cable. pi-webrtc reads it with libcamera on a Raspberry Pi, and with libargus on a Jetson.
USB Cameras
pi-webrtc reads USB (UVC) cameras through V4L2. They work on a Raspberry Pi and on a Jetson, with no extra setup.
RTSP Cameras
Stream an IP camera, or any RTSP stream, through pi-webrtc. Run pi-webrtc on a Raspberry Pi or a Jetson near the camera, and point --camera at an rtsp:// URL.
Virtual Cameras
Process camera frames in your own program first, for example with OpenCV or an AI model. Then write the result to a virtual camera, and stream it with pi-web...
Encoding
pi-webrtc encodes the video for each WebRTC connection, so each connection can follow its own network. This page shows which encoder it uses, and how the fra...
Low Bitrate
When the network slows down, WebRTC lowers the video bitrate. In adaptive mode (the default) it also lowers the resolution, one step at a time and at the sam...
Two-way Audio
pi-webrtc can send audio from a microphone on the device, and play audio from the viewer on a speaker.
Signaling
Before video can flow, the browser and the device must exchange connection details (an SDP offer and answer, and ICE candidates). This step is called signali...
WHEP
WHEP (WebRTC-HTTP Egress Protocol) lets any WHEP player play the stream from a URL. pi-webrtc serves WHEP itself, so you need no broker and no account.
MQTT
Watch the camera from anywhere, without a public IP address or port forwarding. The device and the browser exchange connection details through an MQTT broker...
SFU
An SFU (Selective Forwarding Unit) lets many people watch one device. The device sends one stream to the SFU, and the SFU forwards it to every viewer.
TURN
Use a TURN server when a peer-to-peer connection fails, for example over 4G or 5G. A TURN server relays the video between the device and the browser.
Self-hosted Mosquitto
Run your own MQTT broker instead of a cloud service. Mosquitto is a small and popular MQTT broker for Linux.
Recording
pi-webrtc can save MP4 video files and JPEG snapshots on the device, all the time or only when a viewer asks. Recording uses the full camera resolution, even...
Integrations
Connect pi-webrtc to your own software. Send messages both ways, read a gamepad, show the camera in Home Assistant, or stream from a ROS robot.
IPC Messages
Send data both ways between the browser and a program on the device: AI events, sensor values, or remote-control commands. pi-webrtc passes the messages betw...
Gamepad
Control the device with a gamepad that is connected to the browser. pi-webrtc sends the gamepad state to a Unix socket on the device, as simple JSON lines. Y...
Home Assistant
Show the camera on a Home Assistant dashboard. Home Assistant plays the stream over WHEP with the WebRTC Camera integration.
ROS
Stream a ROS 2 image topic to the browser with pi-webrtc, and drive the robot with a gamepad from the same browser.
Deployment
Run pi-webrtc for real: start it when the device boots, run several cameras, and tune it for low delay.
Run as a Service
Start pi-webrtc when the device boots, and restart it if it stops. This page uses systemd.
Multiple Cameras
Stream several cameras from one device. Run one pi-webrtc process per camera, or use the sponsor build to run all of them in one process.
Performance
Measure where the delay comes from, and make the device faster.
Reference
Look up every option and the protocol details.
Configuration
Every option can be given either as a command-line flag or as a key in a YAML config file. Command-line arguments always win over the file.
DataChannels
pi-webrtc uses WebRTC DataChannels for commands, file transfers and IPC messages. This page lists the channels, which signaling carries them, and the command...
Development
Build pi-webrtc from source, and learn how the code is organized. You only need this to change pi-webrtc itself. The releases are ready to use.
Build from Source
Build pi-webrtc on the device itself: a Raspberry Pi with Raspberry Pi OS Trixie (64-bit), or a Jetson with JetPack 6.
Architecture
pi-webrtc is one process that pulls frames from a camera once and fans them out to three consumers: the WebRTC encoder, the recorder, and — in the sponsor bu...

