https://github.com/splithor1zon/pikvm-webcam
Simple guide for setting up webcam, camera streaming on your PiKVM system.
https://github.com/splithor1zon/pikvm-webcam
camera pikvm webcam webcam-streaming
Last synced: 6 months ago
JSON representation
Simple guide for setting up webcam, camera streaming on your PiKVM system.
- Host: GitHub
- URL: https://github.com/splithor1zon/pikvm-webcam
- Owner: splithor1zon
- Created: 2024-08-01T15:22:06.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-16T18:31:30.000Z (12 months ago)
- Last Synced: 2025-03-28T11:33:01.050Z (6 months ago)
- Topics: camera, pikvm, webcam, webcam-streaming
- Homepage:
- Size: 17.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
*Accepting suggestions, just create a new issue.* 🤝
# PiKVM-webcam
Simple guide for setting up webcam streaming from your PiKVM system. Tested on PiKVM V4 Plus. Useful for setting up BIOS settings on laptops, or completely reinstalling the OS. Keyboard input function of kvmd works even if the HDMI input is not connected.
## Prepare the PiKVM system
1. `pikvm-update` - update the system, probably reboot required
1. `rw` - enable writing to filesystem
1. `pacman -S ffmpeg` - install ffmpeg## Download the mediamtx app
Copy download link for latest release of mediamtx (linux_armv7), you can find the download link here: https://github.com/bluenviron/mediamtx/releases
1. `wget `
1. `tar -xvf `
1. `mv mediamtx /usr/local/bin/`
1. `mv mediamtx.yml /usr/local/etc/`## Create systemd service
`nano /etc/systemd/system/mediamtx.service`
```
[Unit]
Wants=network.target
[Service]
ExecStart=/usr/local/bin/mediamtx /usr/local/etc/mediamtx.yml
[Install]
WantedBy=multi-user.target
```## Edit mediamtx config file:
`nano /usr/local/etc/mediamtx.yml`
At the end of file modify the "paths" section as:
```
paths:
cam:
runOnDemand: ffmpeg -f v4l2 -input_format mjpeg -s 1920x1080 -r 10 -i /dev/webcam -c:v h264_v4l2m2m -pix_fmt yuv420p -b:v 6M -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
runOnDemandRestart: yes
cam-lq:
runOnDemand: ffmpeg -f v4l2 -input_format mjpeg -s 1280x720 -r 5 -i /dev/webcam -c:v h264_v4l2m2m -pix_fmt yuv420p -b:v 2M -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
runOnDemandRestart: yes
cam-hq:
runOnDemand: ffmpeg -f v4l2 -input_format mjpeg -s 1920x1080 -r 20 -i /dev/webcam -c:v h264_v4l2m2m -pix_fmt yuv420p -b:v 20M -f rtsp rtsp://localhost:$RTSP_PORT/$MTX_PATH
runOnDemandRestart: yes
all_others:
```## Create udev rule
This is to mount the webcam consistently to a single /dev mapping point. You can find name and index attributes for your exact webcam using `udevadm info -a -p $(udevadm info -q path -n /dev/videoX)`, where `/dev/videoX` is current mapping of your webcam.
`nano /etc/udev/rules.d/99-webcam.rules`
```
SUBSYSTEM=="video4linux", ATTR{index}=="0", ATTR{name}=="Logitech Webcam C925e", SYMLINK+="webcam"
```## Enable service and reboot:
1. `sudo systemctl daemon-reload`
1. `sudo systemctl enable mediamtx`
1. `reboot`## Camera web access:
Stream quality switch takes ~20 seconds. Multiple streams are possible only in single quality. If webcam USB is disconncted/reconnected just refreshing the stream page should get it running again.
### Using WebRTC (UDP required)
You can access the stream through a web browser supporting WebRTC, access to UDP is required.
- `:8889/cam/` = normal quality (1920x1080, 10fps, 6Mbit max, ~3Mbit avg)
- `:8889/cam-lq/` = low quality (1280x720, 5fps, 2Mbit max, ~500kbit avg)
- `:8889/cam-hq/` = high quality (1920x1080, 20fps, 20Mbit max ~10Mbit avg)### Using RTSP
For TCP only environments you can use RTSP stream through VLC:
- `rtsp://:8554/cam/` = normal quality (1920x1080, 10fps, 6Mbit max, ~3Mbit avg)
- `rtsp://:8554/cam-lq/` = low quality (1280x720, 5fps, 2Mbit max, ~500kbit avg)
- `rtsp://:8554/cam-hq/` = high quality (1920x1080, 20fps, 20Mbit max ~10Mbit avg)Be sure to set up network caching parameter when connecting to the stream according to the latency and stability of your network for lower latency stream.