diff --git a/README.md b/README.md index a6987c7..1f7f5b2 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,22 @@ sudo make install There are three modes of operation implemented offering different compatibility to performance. +### Use a preconfigured systemd services + +The simplest is to use preconfigured `service/camera-streamer*.service`. +Those can be used as an example, and can be configured to fine tune parameters. + +Example: + +```bash +systemctl enable $PWD/service/camera-streamer-arducam-16MP.service +systemctl start camera-streamer-arducam-16MP +``` + +If everything was OK, there will be web-server at `http://:8080/`. + +Error messages can be read `journalctl -xef -u camera-streamer-arducam-16MP`. + ### High-compatibility via `libcamera` This script uses `libcamera` to access camera and provide diff --git a/service/camera-streamer.service b/service/camera-streamer-arducam-16MP.service similarity index 65% rename from service/camera-streamer.service rename to service/camera-streamer-arducam-16MP.service index 33fc3b7..7beea38 100644 --- a/service/camera-streamer.service +++ b/service/camera-streamer-arducam-16MP.service @@ -3,21 +3,22 @@ Description=camera-streamer web camera After=network.target [Service] -User=nobody -Group=nogroup -SupplementaryGroups=video i2c ExecStart=/usr/local/bin/camera-streamer \ -camera-path=/base/soc/i2c0mux/i2c@1/imx519@1a \ -camera-type=libcamera \ -camera-format=YUYV \ -camera-width=2328 -camera-height=1748 \ - -camera-high_res_factor=1.5 \ - -camera-fps=30 -# set auto-focus for IMX519 -ExecStartPost=-/bin/bash -c 'sleep 3s; /usr/sbin/i2ctransfer -y 11 w4@0x0c 0x0 0x85 0x00 0x00' + -camera-fps=30 \ + -camera-nbufs=2 \ # use two memory buffers to optimise usage + -camera-high_res_factor=1.5 \ # the high-res is 1552x1165 + -camera-low_res_factor=3.0 \ # the low-res is 776x582 + -camera-options=brightness=0.1 # bump brightness slightly + +User=nobody +Group=nogroup +SupplementaryGroups=video i2c Restart=always RestartSec=10 - Nice=10 IOSchedulingClass=idle IOSchedulingPriority=7 diff --git a/service/camera-streamer-arducam-64MP.service b/service/camera-streamer-arducam-64MP.service new file mode 100644 index 0000000..528c151 --- /dev/null +++ b/service/camera-streamer-arducam-64MP.service @@ -0,0 +1,32 @@ +[Unit] +Description=camera-streamer web camera +After=network.target + +[Service] +ExecStartPre=-/usr/bin/v4l2-ctl -d /dev/v4l-subdev1 -c focus_absolute=2200 # set fixed-focus +ExecStart=/usr/local/bin/camera-streamer \ + -camera-path=/base/soc/i2c0mux/i2c@1/arducam_64mp@1a \ + -camera-type=libcamera \ + -camera-format=YUYV \ + -camera-width=2328 -camera-height=1748 \ + -camera-fps=30 \ + -camera-nbufs=2 \ # use two memory buffers to optimise usage + -camera-high_res_factor=1.5 \ # the high-res is 1552x1165 + -camera-low_res_factor=3.0 \ # the low-res is 776x582 + -camera-options=brightness=0.1 \ # bump brightness slightly + -camera-auto-focus=0 # disable auto-focus + +User=nobody +Group=nogroup +SupplementaryGroups=video i2c +Restart=always +RestartSec=10 +Nice=10 +IOSchedulingClass=idle +IOSchedulingPriority=7 +CPUWeight=20 +AllowedCPUs=1-2 +MemoryMax=250M + +[Install] +WantedBy=multi-user.target diff --git a/service/camera-streamer-usb-cam.service b/service/camera-streamer-usb-cam.service new file mode 100644 index 0000000..e00f0ba --- /dev/null +++ b/service/camera-streamer-usb-cam.service @@ -0,0 +1,28 @@ +[Unit] +Description=camera-streamer web camera +After=network.target + +[Service] +ExecStart=/usr/local/bin/camera-streamer \ + -camera-path=/dev/video0 \ + -camera-format=JPEG \ + -camera-width=1920 -camera-height=1080 \ + -camera-fps=30 \ + -camera-nbufs=2 \ # use two memory buffers to optimise usage + -camera-high_res_factor=1.0 \ # the high-res is 1920x1080 + -camera-low_res_factor=2.0 # the low-res is 960x540 + +User=nobody +Group=nogroup +SupplementaryGroups=video i2c +Restart=always +RestartSec=10 +Nice=10 +IOSchedulingClass=idle +IOSchedulingPriority=7 +CPUWeight=20 +AllowedCPUs=1-2 +MemoryMax=250M + +[Install] +WantedBy=multi-user.target