chore: refactor log output of rtsp-simple-server
Signed-off-by: Stephan Wendel <me@stephanwe.de>
This commit is contained in:
@@ -16,10 +16,10 @@
|
||||
# Exit upon Errors
|
||||
set -Ee
|
||||
|
||||
function run_rtsp {
|
||||
run_rtsp() {
|
||||
local cams
|
||||
cams="${1}"
|
||||
if [ -z "$(pidof rtsp-simple-server)" ]; then
|
||||
if [[ -z "$(pidof rtsp-simple-server)" ]]; then
|
||||
run_rtsp_srv &
|
||||
fi
|
||||
for instance in ${cams} ; do
|
||||
@@ -28,14 +28,14 @@ function run_rtsp {
|
||||
}
|
||||
|
||||
|
||||
function run_ffmpeg {
|
||||
run_ffmpeg() {
|
||||
local cam_section ffmpeg_bin start_param
|
||||
cam_section="${1}"
|
||||
ffmpeg_bin="$(whereis ffmpeg | awk '{print $2}')"
|
||||
dev="$(get_param "cam ${cam_section}" device)"
|
||||
# Construct start_param
|
||||
start_param=( -nostdin -hide_banner -f video4linux2 )
|
||||
if [ "$(detect_h264 "${cam_section}")" = "1" ]; then
|
||||
if [[ "$(detect_h264 "${cam_section}")" = "1" ]]; then
|
||||
start_param+=( -input_format h264 -pix_fmt h264 )
|
||||
else
|
||||
start_param+=( -input_format yuyv422 )
|
||||
@@ -45,8 +45,8 @@ function run_ffmpeg {
|
||||
-framerate "$(get_param "cam ${cam_section}" max_fps)"
|
||||
-i "${dev}"
|
||||
)
|
||||
if [ "$(detect_h264 "${cam_section}")" -eq 0 ] &&
|
||||
[ "$(check_omx)" -eq 1 ]; then
|
||||
if [[ "$(detect_h264 "${cam_section}")" -eq 0 ]] &&
|
||||
[[ "$(check_omx)" -eq 1 ]]; then
|
||||
start_param+=( -c:v h264_omx -b:v 8M )
|
||||
else
|
||||
start_param+=( -c:v copy )
|
||||
@@ -63,18 +63,18 @@ function run_ffmpeg {
|
||||
log_msg "ERROR: Start of ffmpeg (rtsp stream source) [cam ${cam_section}] failed!"
|
||||
}
|
||||
|
||||
function run_rtsp_srv {
|
||||
run_rtsp_srv() {
|
||||
local rtsp_bin config
|
||||
rtsp_bin="${BASE_CN_PATH}/bin/rtsp-simple-server/rtsp-simple-server"
|
||||
config="${BASE_CN_PATH}/resources/crowsnest-rtsp.yml"
|
||||
log_msg "Starting rtsp-simple-server with config ${config} ..."
|
||||
echo "Config file: ${config}" | \
|
||||
log_output "rtsp-simple-server [cam ${cam_section}]"
|
||||
log_output "rtsp-simple-server [INFO]"
|
||||
# Start rtsp-simple-server
|
||||
# Have to use this dirty bash hack to get output to logfile.
|
||||
"${rtsp_bin}" "${config}" &> >(log_output "rtsp-simple-server [cam ${cam_section}]")
|
||||
"${rtsp_bin}" "${config}" &> >(log_output "rtsp-simple-server")
|
||||
# Should not be seen else failed.
|
||||
log_msg "ERROR: Start of rtsp-simple failed!"
|
||||
echo "Config file: ${config}" | \
|
||||
log_output "rtsp-simple-server [cam ${cam_section}]"
|
||||
log_output "rtsp-simple-server [ERROR]"
|
||||
}
|
||||
|
Reference in New Issue
Block a user