pi-webrtc

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.

Raspberry Pi (libcamera)

Use --camera=libcamera:<id>. The first camera is 0. A Pi 5 with two cameras also has 1.

./pi-webrtc --camera=libcamera:0 --width=1280 --height=720 --fps=30 ...

Keep the default camera_auto_detect=1 in /boot/firmware/config.txt. List the cameras with:

rpicam-hello --list-cameras

The image controls, such as --awb, --ev and autofocus, work like in rpicam-apps. See Image controls.

Jetson (libargus)

Use --camera=libargus:<id>:

./pi-webrtc --camera=libargus:0 --width=1920 --height=1080 --fps=30 --hw-accel ...

The frames stay in GPU memory. The encoder reads them there, without a copy through the CPU.

Sub-stream

A CSI camera can also give a second, smaller stream at the same time, on both a Raspberry Pi and a Jetson. For example, you can record at full size and stream a smaller copy:

./pi-webrtc --camera=libcamera:0 --width=1280 --height=720 \
  --sub-width=640 --sub-height=360 --webrtc-source=sub --record-source=main ...

See Sub-stream.

Bandwidth limits

A CSI camera sends uncompressed YUV 4:2:0 frames. Each pixel needs 12 bits. So the link to the camera often limits the size and frame rate, not the sensor.

Each MIPI lane carries 1.5 Gbps on the Pi 5 and 1 Gbps on older models [ref]:

Interface1-lane MIPI (older Pi)2-lane MIPI (Pi 4)4-lane MIPI (Pi 5)USB 2.0USB 3.0
Bandwidth1 Gbps2 Gbps6 Gbps0.48 Gbps5 Gbps

For example, 4K at 60 fps needs 3840 × 2160 × 60 × 12 bits per second, which is 5.56 Gbps:

Resolution4K, 60 fps4K, 30 fps1080p, 60 fps1080p, 30 fps
Bandwidth5.56 Gbps2.78 Gbps1.39 Gbps0.70 Gbps
Edit on GitHub

On this page