CreatBotCrowsnest/libs/ustreamer.sh
Stephan Wendel f6e2156ab3
Merge develop branch (#163)
* Fix makefile flags on low memory devices (#124)

* Fix `makefile` flags on low memory devices

On devices with less than 512MB existing devices will use `-j2` due to wrong condition.

* docs: Update index with correct heading and link to backends (#131)

This is a follow-up to #108 and fixes heading and hyperlink to the list of backends

* Typo in `core.sh` (#138)

* Fix makefile flags on low memory devices (#124) (#125)

* Fix `makefile` flags on low memory devices

On devices with less than 512MB existing devices will use `-j2` due to wrong condition.

Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu>

* Typo in `core.sh`

'Dependencys' --> dependencies

---------

Co-authored-by: Stephan Wendel <43513802+KwadFan@users.noreply.github.com>
Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu>

* Fix makefile flags on low memory devices (#124) (#125) (#144)

* Fix `makefile` flags on low memory devices

On devices with less than 512MB existing devices will use `-j2` due to wrong condition.

Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu>

* docs(messages.sh): fix typos, improve spelling (#145)

* feat: add legacy cam support (#146)

* feat: add legacy cam support

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* feat: add blockyfix

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* fix: add ustreamer legacy cam workaround

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

---------

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* Fix makefile flags on low memory devices (#124) (#125) (#147)

* Fix `makefile` flags on low memory devices

On devices with less than 512MB existing devices will use `-j2` due to wrong condition.

Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu>

* fix: fix make config empty path (#148)

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* fix: fix default_path_msg function name (#149)

* fix: fix default_path_msg function name

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* fix: fix message

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

---------

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* fix: fix libcamera-apps-lite not getting updated (#160)

libcamera-apps-lite is needed for libcamera-hello.
Crowsnest uses libcamera-hello to detected raspicams

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* fix: fix Shellcheck test error (#153)

* fix: fix Shellcheck test error

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* style: remove empty condition

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

---------

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

* fix: fix CustomPiOS docker build error (#158)

This should skip any check of `SUDO_USER`

Tested with Win & Linux host with Docker 

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>

---------

Signed-off-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>
Co-authored-by: Kamil Trzciński <ayufan@ayufan.eu>
Co-authored-by: DeviousFusion <dj3tusk@gmail.com>
Co-authored-by: Sergei <67871383+slepiavka@users.noreply.github.com>
Co-authored-by: Patrick Gehrsitz <58853838+mryel00@users.noreply.github.com>
2023-08-11 18:04:33 +02:00

81 lines
2.4 KiB
Bash
Executable File

#!/bin/bash
#### ustreamer library
#### crowsnest - A webcam Service for multiple Cams and Stream Services.
####
#### Written by Stephan Wendel aka KwadFan <me@stephanwe.de>
#### Copyright 2021
#### https://github.com/mainsail-crew/crowsnest
####
#### This File is distributed under GPLv3
####
# shellcheck enable=require-variable-braces
# Exit upon Errors
set -Ee
run_mjpg() {
local cams
v4l2_control
cams="${1}"
for instance in ${cams} ; do
run_ustreamer "${instance}" &
done
blockyfix
brokenfocus
return
}
run_ustreamer() {
local cam_sec ust_bin dev pt res fps cstm start_param
cam_sec="${1}"
ust_bin="${BASE_CN_PATH}/bin/ustreamer/ustreamer"
dev="$(get_param "cam ${cam_sec}" device)"
pt="$(get_param "cam ${cam_sec}" port)"
res="$(get_param "cam ${cam_sec}" resolution)"
fps="$(get_param "cam ${cam_sec}" max_fps)"
cstm="$(get_param "cam ${cam_sec}" custom_flags 2> /dev/null)"
noprx="$(get_param "crowsnest" no_proxy 2> /dev/null)"
# construct start parameter
if [[ -n "${noprx}" ]] && [[ "${noprx}" = "true" ]]; then
start_param=( --host 0.0.0.0 -p "${pt}" )
log_msg "INFO: Set to 'no_proxy' mode! Using 0.0.0.0 !"
else
start_param=( --host 127.0.0.1 -p "${pt}" )
fi
#Raspicam Workaround
if [[ "${dev}" = "$(dev_is_legacy)" ]]; then
start_param+=( -m MJPEG --device-timeout=5 --buffers=3 )
else
# Add device
start_param+=( -d "${dev}" --device-timeout=2 )
# Use MJPEG Hardware encoder if possible
if [ "$(detect_mjpeg "${cam_sec}")" = "1" ]; then
start_param+=( -m MJPEG --encoder=HW )
fi
fi
# set max framerate
start_param+=( -r "${res}" -f "${fps}" )
# webroot & allow crossdomain requests
start_param+=( --allow-origin=\* --static "${BASE_CN_PATH}/ustreamer-www" )
# Custom Flag Handling (append to defaults)
if [[ -n "${cstm}" ]]; then
start_param+=( "${cstm}" )
fi
# Log start_param
log_msg "Starting ustreamer with Device ${dev} ..."
echo "Parameters: ${start_param[*]}" | \
log_output "ustreamer [cam ${cam_sec}]"
# Start ustreamer
echo "${start_param[*]}" | xargs "${ust_bin}" 2>&1 | \
log_output "ustreamer [cam ${cam_sec}]"
# Should not be seen else failed.
log_msg "ERROR: Start of ustreamer [cam ${cam_sec}] failed!"
}