How to setup Pi to serve RGB and Thermal footage from cameras.
We're using the Logitech webcam c270 and Seek Compat for RGB and Thermal respectively.
Download mediamtx binary from: https://github.com/bluenviron/mediamtx/releases
Latest version is v1.8.3 as of writing, change it accordingly.
And extract
wget https://github.com/bluenviron/mediamtx/releases/download/v1.8.3/mediamtx_v1.8.3_linux_amd64.tar.gz
mkdir ./mediamtx
tar -xf mediamtx_v1.8.3_linux_amd64.tar.gz -C ./mediamtx
running the server:
cd ./mediamtx
./mediamtx
- Clone from github:
git clone https://github.com/umlaeute/v4l2loopback
- switch to latest release tag:
v0.12.7 - build and install module
make && sudo make install
sudo depmod -a
- load mod as root
sudo modprobe v4l2loopback video_nr=2
Will create a loopback device at /dev/video2
- Change fps of device
cd ./utils/v4l2loopback-ctl set-fps 10 /dev/video2
Will force set 10fps
- cmake
- libopencv-dev (>= 2.4)
- libusb-1.0-0-dev
- ffmpeg
sudo apt install cmake libopencv-dev libusb-1.0-0-dev ffmpeg
- clone repo
git clone https://github.com/OpenThermal/libseek-thermal
cd ./libseek-thermal
- apply dead pixel fix:
- copy
dead_pixel.patchto libseek-thermal root, then apply the patch:
- copy
git apply ./dead_pixel.patch
- build
cd libseek-thermal
mkdir build
cd build
cmake ..
make
- install
sudo make install
sudo ldconfig
- download
10-seekthermal.rulesfile and add udev rule:
# make sure 10-seekthermal.rule in current dir
sudo cp 10-seekthermal.rules /etc/udev/rules.d
sudo udevadm control --reload
- push thermal stream to v4l2 loopback device
seek_viewer --colormap=11 --rotate=0 --mode=v4l2 --output=/dev/video2
- push stream to rtsp via ffmpeg
ffmpeg -i /dev/video2 -b:v 2000k -f rtsp rtsp://localhost:8554/thermal
-b:v: for setting bitrate- url format: rtsp://:8554/
- endpoint is arbitrary
- Find the camera device with v4l2-ctl:
sudo apt install v4l-utils
v4l2-ctl --list-devices
- Push stream to rtsp server:
ffmpeg -i /dev/videoX -b:v 2000k -f rtsp rtsp://localhost:8554/camera
-b:v: for setting bitrateurl: rtsp://localhost:8554/, endpoint is arbitrary
ffplay -fflags nobuffer -flags low_delay -framedrop rtsp://<host>:8554/thermal
ffplay -fflags nobuffer -flags low_delay -framedrop rtsp://<host>:8554/camera
-fflags nobuffer -flags low_delay -framedropare flags for streaming with low latency