Raspi als WebCam Server
RunBook incl. Installation
# Runbook -- Raspberry Pi Webcam-Streaming mit Logitech C920 und MediaMTX
**Version:** 2.0\
**Stand:** Juli 2026
------------------------------------------------------------------------
# Inhaltsverzeichnis
1. Ziel
2. Architektur
3. Hardware
4. Software
5. Voraussetzungen
6. Installation
7. Webcam testen
8. FFmpeg installieren
9. MediaMTX installieren
10. MediaMTX konfigurieren
11. Systemd-Dienste
12. Funktionstest
13. OBS einrichten
14. VLC-Test
15. Fehlerbehebung
16. Wartung
17. Updates
18. Mehrere Webcams
19. Performance
20. Backup
------------------------------------------------------------------------
# 1. Ziel
Bereitstellung einer Logitech C920 als RTSP-Stream für:
- OBS
- VLC
- Home Assistant
- weitere RTSP-Clients
------------------------------------------------------------------------
# 2. Architektur
``` text
Logitech C920
│
▼
Raspberry Pi
│
/dev/video0
│
FFmpeg (H.264)
│
MediaMTX
│
rtsp://<IP>:8554/webcam
│
├── OBS
├── VLC
└── Home Assistant
```
------------------------------------------------------------------------
# 3. Hardware
- Raspberry Pi 4 oder 5 (64 Bit empfohlen)
- Logitech C920
- stabiles Netzteil
- Netzwerkverbindung
------------------------------------------------------------------------
# 4. Software
- Raspberry Pi OS 64 Bit
- FFmpeg
- MediaMTX
------------------------------------------------------------------------
# 5. Voraussetzungen
``` bash
uname -a
```
Sollte `aarch64` enthalten.
------------------------------------------------------------------------
# 6. Installation
## Webcam prüfen
``` bash
lsusb
ls /dev/video*
v4l2-ctl --all
v4l2-ctl --list-formats-ext
```
Auflösung setzen:
``` bash
v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=MJPG
v4l2-ctl --set-parm=30
```
## FFmpeg
``` bash
sudo apt update
sudo apt install ffmpeg
```
## MediaMTX
``` bash
cd /tmp
wget https://github.com/bluenviron/mediamtx/releases/download/v1.19.2/mediamtx_v1.19.2_linux_arm64.tar.gz
tar xzf mediamtx_v1.19.2_linux_arm64.tar.gz
sudo mv mediamtx /usr/local/bin/
sudo mkdir -p /etc/mediamtx
sudo cp mediamtx.yml /etc/mediamtx/
```
Version:
``` bash
mediamtx --version
```
------------------------------------------------------------------------
# 7. MediaMTX konfigurieren
Datei:
`/etc/mediamtx/mediamtx.yml`
``` yaml
paths:
webcam:
```
------------------------------------------------------------------------
# 8. systemd-Dienst MediaMTX
Datei:
`/etc/systemd/system/mediamtx.service`
``` ini
[Unit]
Description=MediaMTX RTSP Server
After=network.target
[Service]
ExecStart=/usr/local/bin/mediamtx /etc/mediamtx/mediamtx.yml
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
```
Aktivieren:
``` bash
sudo systemctl daemon-reload
sudo systemctl enable mediamtx
sudo systemctl start mediamtx
```
------------------------------------------------------------------------
# 9. Webcam-Dienst
Datei:
`/etc/systemd/system/webcam.service`
``` ini
[Unit]
Description=Logitech C920 RTSP Stream
After=mediamtx.service
Requires=mediamtx.service
[Service]
ExecStart=/usr/bin/ffmpeg \
-f v4l2 \
-input_format mjpeg \
-framerate 30 \
-video_size 1920x1080 \
-i /dev/video0 \
-c:v libx264 \
-preset ultrafast \
-tune zerolatency \
-pix_fmt yuv420p \
-f rtsp \
-rtsp_transport tcp \
rtsp://127.0.0.1:8554/webcam
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
```
Aktivieren:
``` bash
sudo systemctl daemon-reload
sudo systemctl enable webcam
sudo systemctl start webcam
```
------------------------------------------------------------------------
# 10. Funktionstest
## Dienste
``` bash
systemctl status mediamtx
systemctl status webcam
```
## Logs
``` bash
journalctl -u mediamtx -f
journalctl -u webcam -f
```
## Port
``` bash
ss -tulpn | grep 8554
```
## Kamera
``` bash
sudo fuser -v /dev/video0
```
------------------------------------------------------------------------
# 11. OBS
Quelle:
**Medienquelle**
URL:
``` text
rtsp://192.168.190.69:8554/webcam
```
Lokale Datei deaktivieren.
------------------------------------------------------------------------
# 12. VLC
``` text
rtsp://192.168.190.69:8554/webcam
```
------------------------------------------------------------------------
# 13. Home Assistant
``` yaml
camera:
- platform: ffmpeg
name: Logitech C920
input: rtsp://192.168.190.69:8554/webcam
```
------------------------------------------------------------------------
# 14. Fehlerbehebung
## Device or resource busy
``` bash
sudo fuser -v /dev/video0
```
## Prozesse
``` bash
ps -ef | grep ffmpeg
ps -ef | grep mediamtx
```
## Neustart
``` bash
sudo systemctl restart mediamtx
sudo systemctl restart webcam
```
------------------------------------------------------------------------
# 15. Performance
CPU:
``` bash
top
```
Temperatur:
``` bash
vcgencmd measure_temp
```
------------------------------------------------------------------------
# 16. Mehrere Kameras
Weitere Pfade in MediaMTX:
``` yaml
paths:
webcam1:
webcam2:
```
Weitere systemd-Dienste:
- webcam1.service
- webcam2.service
------------------------------------------------------------------------
# 17. Updates
MediaMTX:
1. neue Version herunterladen
2. Binary ersetzen
3. Dienst neu starten
``` bash
sudo systemctl restart mediamtx
```
------------------------------------------------------------------------
# 18. Backup
Sichern:
- /etc/mediamtx
- /etc/systemd/system/webcam.service
- /etc/systemd/system/mediamtx.service
------------------------------------------------------------------------
# Versionshistorie
Version Beschreibung
--------- -------------------------------------------------
1.0 Erste Version
2.0 Erweitertes Installations- und Wartungs-Runbook