Skip to content

Commit e604f9e

Browse files
committed
WIP: camera-streamer instead of current webcam stuff
- webcamd replaced by some fun systemd files - mjpg-streamer replaced by camera-streamer works with USB and libcamera devices incl raspi cam v3
1 parent 7ffb82d commit e604f9e

11 files changed

Lines changed: 176 additions & 522 deletions

scripts/10-install-arducam-mjpg-streamer

Lines changed: 0 additions & 59 deletions
This file was deleted.

scripts/10-install-camera-streamer

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
set -x
2+
set -e
3+
4+
export LC_ALL=C
5+
6+
source /common.sh
7+
install_cleanup_trap
8+
9+
apt-get install --yes libavformat-dev libavutil-dev libavcodec-dev libcamera-dev liblivemedia-dev v4l-utils pkg-config xxd build-essential cmake libssl-dev
10+
11+
cp /files/camera-streamer/camera-streamer.zip /tmp/camera-streamer.zip
12+
unzip /tmp/camera-streamer.zip -d /tmp/camera-streamer
13+
rm /tmp/camera-streamer.zip
14+
15+
pushd /tmp/camera-streamer/camera-streamer
16+
make -j$(nproc)
17+
make install
18+
popd
19+
rm -rf /tmp/camera-streamer
20+
21+
sed -i 's/^camera_auto_detect=0/camera_auto_detect=1/' /boot/config.txt
22+
23+
cp /files/camera-streamer/camera-streamer.conf /boot/camera-streamer.conf
24+
25+
cp /files/camera-streamer/camera-streamer-libcamera.service /etc/systemd/system/camera-streamer-libcamera.service
26+
systemctl enable camera-streamer-libcamera.service
27+
28+
cp /files/camera-streamer/camera-streamer-usb.service /etc/systemd/system/camera-streamer-usb.service
29+
systemctl enable camera-streamer-usb.service
30+
31+
cp /files/camera-streamer/camera-streamer-usb.path /etc/systemd/system/camera-streamer-usb.path
32+
systemctl enable camera-streamer-usb.path
33+
34+
# prepare multicam template folder
35+
cp /files/camera-streamer/camera-streamer-usb-multi@.service /etc/systemd/system/camera-streamer-usb-multi@.service
36+
systemctl enable camera-streamer-usb.service
37+
38+
mkdir -p /boot/camera-streamer.conf.d
39+
cp /files/camera-streamer/multi-example.conf /boot/camera-streamer.conf.d/example.conf
40+
41+
# clean up the old crap
42+
systemctl disable webcamd
43+
rm /root/bin/webcamd
44+
rm -rf /opt/mjpg-streamer

scripts/11-install-libcamera-webcamd

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[Unit]
2+
Description=camera-streamer libcamera
3+
After=network.target
4+
ConditionPathExistsGlob=/sys/bus/i2c/drivers/*/*/video4linux
5+
6+
[Service]
7+
EnvironmentFile=/boot/camera-streamer.conf
8+
ExecStart=/usr/local/bin/camera-streamer \
9+
-camera-type=libcamera \
10+
; YUYV offers best quality in camera-streamer
11+
-camera-format=YUYV \
12+
-camera-width=${LIBCAMERA_WIDTH} -camera-height=${LIBCAMERA_HEIGHT} \
13+
-camera-fps=${LIBCAMERA_FRAMERATE} \
14+
-camera-nbufs=2 \
15+
-camera-high_res_factor=1 \
16+
-camera-low_res_factor=2 \
17+
${LIBCAMERA_OPTIONS}
18+
19+
DynamicUser=yes
20+
SupplementaryGroups=video i2c
21+
Restart=always
22+
RestartSec=10
23+
Nice=10
24+
IOSchedulingClass=idle
25+
IOSchedulingPriority=7
26+
CPUWeight=20
27+
AllowedCPUs=1-2
28+
MemoryMax=250M
29+
30+
[Install]
31+
WantedBy=multi-user.target
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
[Unit]
2+
Description=camera-streamer usb %i
3+
After=network.target
4+
Conflicts=camera-streamer-usb.service
5+
ConditionPathExistsGlob=/dev/v4l/by-id/usb-*-video-index0
6+
7+
[Service]
8+
EnvironmentFile=/boot/camera-streamer.conf.d/%i.conf
9+
ExecStart=/usr/local/bin/camera-streamer \
10+
-http-port=${HTTP_PORT} \
11+
-camera-path="${USB_PATH}" \
12+
-camera-format=${USB_FORMAT} \
13+
-camera-width=${USB_WIDTH} -camera-height=${USB_HEIGHT} \
14+
-camera-fps=${USB_FRAMERATE} \
15+
-camera-nbufs=2 \
16+
-camera-high_res_factor=1 \
17+
-camera-low_res_factor=2 \
18+
${USB_OPTIONS}
19+
20+
DynamicUser=yes
21+
SupplementaryGroups=video i2c
22+
Restart=always
23+
RestartSec=10
24+
Nice=10
25+
IOSchedulingClass=idle
26+
IOSchedulingPriority=7
27+
CPUWeight=20
28+
AllowedCPUs=1-2
29+
MemoryMax=250M
30+
31+
[Install]
32+
WantedBy=multi-user.target
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[Unit]
2+
Description=camera-streamer usb autolaunch
3+
4+
[Path]
5+
PathExistsGlob=/dev/v4l/by-id/usb-*-video-index0
6+
Unit=camera-streamer-usb.service
7+
8+
[Install]
9+
WantedBy=multi-user.target
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[Unit]
2+
Description=camera-streamer usb
3+
After=network.target
4+
ConditionPathExistsGlob=/dev/v4l/by-id/usb-*-video-index0
5+
ConditionPathExistsGlob=!/sys/bus/i2c/drivers/*/*/video4linux
6+
7+
[Service]
8+
EnvironmentFile=/boot/camera-streamer.conf
9+
ExecStart=/usr/local/bin/camera-streamer \
10+
-camera-format=${USB_FORMAT} \
11+
-camera-width=${USB_WIDTH} -camera-height=${USB_HEIGHT} \
12+
-camera-fps=${USB_FRAMERATE} \
13+
-camera-nbufs=2 \
14+
-camera-high_res_factor=1 \
15+
-camera-low_res_factor=2 \
16+
${USB_OPTIONS}
17+
18+
DynamicUser=yes
19+
SupplementaryGroups=video i2c
20+
Restart=always
21+
RestartSec=10
22+
Nice=10
23+
IOSchedulingClass=idle
24+
IOSchedulingPriority=7
25+
CPUWeight=20
26+
AllowedCPUs=1-2
27+
MemoryMax=250M
28+
29+
[Install]
30+
WantedBy=multi-user.target
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# DO NOT LEAVE ANY OF THESE FIELDS UNSET
2+
3+
### Options for libcamera based cameras (PiCam, Arducam, ...)
4+
5+
LIBCAMERA_WIDTH=1280
6+
LIBCAMERA_HEIGHT=720
7+
LIBCAMERA_FRAMERATE=15
8+
LIBCAMERA_OPTIONS='-camera-options="AfMode=2" -camera-options="AfRange=2" -log-debug=0'
9+
# log-debug=0 is a no-op here and used to make camera-streamer happy
10+
11+
### Options for USB based cameras
12+
13+
USB_FORMAT=YUYV
14+
USB_WIDTH=1280
15+
USB_HEIGHT=720
16+
USB_FRAMERATE=15
17+
USB_OPTIONS='-log-debug=0'
18+
# log-debug=0 is a no-op here and used to make camera-streamer happy
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Example configuration for a multi camera setup
2+
#
3+
# TODO: Explain how to use this
4+
5+
HTTP_PORT=8081
6+
USB_PATH=/dev/video2
7+
USB_FORMAT=YUYV
8+
USB_WIDTH=1280
9+
USB_HEIGHT=720
10+
USB_FRAMERATE=15
11+
USB_OPTIONS='-log-debug=0'
12+
# log-debug=0 is a no-op here and used to make camera-streamer happy

scripts/files/octopi.txt

Lines changed: 0 additions & 96 deletions
This file was deleted.

0 commit comments

Comments
 (0)