A Raspberry Pi webcam streaming setup that broadcasts a live video and audio stream over RTSP and HLS using FFmpeg and MediaMTX.
| Component | Details |
|---|---|
| Board | Raspberry Pi 4 (2GB) |
| Camera | Logitech C200 (any UVC-compatible webcam works) |
The Logitech C200 was modified for the birdhouse installation:
- PCB removed from its housing and mounted on a board inside the birdhouse
- Infrared filter removed from the lens to enable night vision (at the expense of colour accuracy)
- Green LED replaced with an infrared LED to illuminate the nest
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
Webcam (V4L2) ──┐
├─▶ FFmpeg (H.264 hw + AAC) ──RTSP──▶ MediaMTX ─┬─▶ RTSP rtsp://<host>/birdy
Mic (ALSA) ──┘ └─▶ HLS http://<host>/birdy
- FFmpeg captures video via V4L2 and audio via ALSA, encodes H.264
using the VideoCore IV hardware encoder (
h264_v4l2m2m) and AAC for audio, then pushes the stream to MediaMTX over RTSP. - MediaMTX acts as an RTSP multiplexer and rebroadcasts the stream to any number of concurrent consumers over RTSP (port 554) and HLS (port 80).
Starting from a fresh Raspberry Pi OS Lite (Debian 13 / aarch64) installation.
sudo apt update && sudo apt upgrade -y
sudo apt install -y ffmpeg v4l-utils alsa-utils fonts-dejavu-coreFind the video device:
v4l2-ctl --list-devicesExample output:
UVC Camera (046d:0802) (usb-3f980000.usb-1.3):
/dev/video0
/dev/video1
/dev/media3
Use the first entry (e.g. /dev/video0).
Find the audio device:
arecord -lExample output:
card 1: U0x46d0x802 [USB Device 0x46d:0x802], device 0: USB Audio [USB Audio]
Subdevices: 1/1
Subdevice #0: subdevice #0
Note the card and device numbers (e.g. hw:1,0).
Find the supported audio formats and sample rates:
cat /proc/asound/card1/stream0Look for the Format and Rates fields under the Capture section. Use
these to set AUDIO_FORMAT and AUDIO_SAMPLE_RATE in the webcam conf file.
MEDIAMTX_VERSION=v1.18.1
wget https://github.com/bluenviron/mediamtx/releases/download/${MEDIAMTX_VERSION}/mediamtx_${MEDIAMTX_VERSION}_linux_arm64.tar.gz
tar xf mediamtx_${MEDIAMTX_VERSION}_linux_arm64.tar.gz mediamtx
sudo install -m 755 mediamtx /usr/local/bin/mediamtx
rm mediamtx mediamtx_${MEDIAMTX_VERSION}_linux_arm64.tar.gzA dedicated system user with no login shell runs both services, limiting the blast radius if anything goes wrong.
sudo useradd -r -m -d /var/lib/birdy -s /usr/sbin/nologin birdy
sudo usermod -aG video,audio birdyThe video and audio groups are required to access /dev/video* and ALSA
devices respectively.
sudo install -m 755 -o birdy -g birdy scripts/ffmpeg.sh /var/lib/birdy/ffmpeg.sh
sudo install -m 644 -o birdy -g birdy config/mediamtx.yml /var/lib/birdy/mediamtx.ymlInstall the webcam configuration and create the active symlink:
sudo install -d -m 755 /etc/birdy
sudo install -m 644 config/logitech_c200.conf /etc/birdy/logitech_c200.conf
sudo ln -sf /etc/birdy/logitech_c200.conf /etc/birdy/birdy.confIf your video or audio devices differ from the defaults, edit
/etc/birdy/logitech_c200.conf before proceeding. Use the values identified
in step 2.
All webcam-specific parameters (devices, resolution, framerate, audio format)
live in /etc/birdy/birdy.conf. To swap webcams, create a new conf file and
update the symlink:
sudo ln -sf /etc/birdy/<new_webcam>.conf /etc/birdy/birdy.conf
sudo systemctl restart birdysudo install -m 644 systemd/mediamtx.service /etc/systemd/system/mediamtx.service
sudo install -m 644 systemd/birdy.service /etc/systemd/system/birdy.service
sudo systemctl daemon-reload
sudo systemctl enable --now mediamtx birdysystemctl status mediamtx birdy
ffprobe -v quiet -rtsp_transport tcp -show_streams rtsp://localhost/birdy 2>&1 | grep codec_nameExpected output:
codec_name=h264
codec_name=aac
| Protocol | URL |
|---|---|
| RTSP | rtsp://<hostname>/birdy |
| HLS | http://<hostname>/birdy |
Both are available simultaneously — MediaMTX handles any number of concurrent consumers without additional load on FFmpeg.
Tested on Surveillance Station 9.2.5.
- Go to IP Camera → Add → Add manually
- Fill in the fields:
- Name: your camera name
- Brand:
[User Define] - Type:
Streaming RTSP - Path:
rtsp://<hostname>/birdy
- Click Add





