Git Product home page Git Product logo

pikvm-webcam's Introduction

PiKVM-webcam

Simple guide for setting up webcam streaming on 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
  2. rw - enable writing to filesystem
  3. 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 <download link>
  2. tar -xvf <downloaded archive>
  3. mv mediamtx /usr/local/bin/
  4. 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
  2. sudo systemctl enable mediamtx
  3. 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.

  • <IP>:8889/cam/ = normal quality (1920x1080, 10fps, 6Mbit max, ~3Mbit avg)
  • <IP>:8889/cam-lq/ = low quality (1280x720, 5fps, 2Mbit max, ~500kbit avg)
  • <IP>: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://<IP>:8554/cam/ = normal quality (1920x1080, 10fps, 6Mbit max, ~3Mbit avg)
  • rtsp://<IP>:8554/cam-lq/ = low quality (1280x720, 5fps, 2Mbit max, ~500kbit avg)
  • rtsp://<IP>: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.

pikvm-webcam's People

Contributors

splithor1zon avatar

Stargazers

boolayon avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.