improve the method of setting variables via the impdbg utility

This commit is contained in:
Alfonso Gamboa 2022-07-08 17:49:17 -07:00
parent a901c24868
commit c9acdc25bc
2 changed files with 163 additions and 92 deletions

View File

@ -530,54 +530,7 @@ if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
echo "rtsp audio disabled"
fi
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER" > /dev/null 2>&1 &
sleep 5
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER" > /dev/null 2>&1 &
sleep 5
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE" > /dev/null 2>&1 &
sleep 5
else
watch -n30 -t "/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE" > /dev/null 2>&1 &
sleep 5
fi
fi
if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
watch -n30 -t "/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE" > /dev/null 2>&1 &
sleep 5
fi
fi
if [[ "$RTSP_HI_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS" > /dev/null 2>&1 &
sleep 5
else
watch -n30 -t "/system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS" > /dev/null 2>&1 &
sleep 5
fi
fi
else
else
echo "rtsp disabled"
fi
@ -609,50 +562,7 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
echo "rtsp audio disabled"
fi
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 &
sleep 5
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 &
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 &
sleep 5
else
watch -n30 -t "/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 &
fi
fi
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
watch -n30 -t "/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE" > /dev/null 2>&1 &
fi
fi
if [[ "$RTSP_LOW_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
watch -n30 -t "/system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS" > /dev/null 2>&1 &
sleep 5
else
watch -n30 -t "/system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS" > /dev/null 2>&1 &
fi
fi
else
else
echo "rtsp disabled"
fi
@ -662,6 +572,9 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true
#This delay is required. Sometimes, if you start the rtsp server too soon, live view will break on the app.
sleep 5
LD_LIBRARY_PATH=/opt/wz_mini/lib /opt/wz_mini/bin/v4l2rtspserver $AUDIO_CH $AUDIO_FMT -F0 -U "$RTSP_LOGIN":"$RTSP_PASSWORD" -P "$RTSP_PORT" $DEVICE1 $DEVICE2 &
sleep 1
echo "Set imp variables via helper"
/opt/wz_mini/usr/bin/imp_helper.sh > /dev/null 2>&1 &
fi
if ([[ "$RTSP_LOW_RES_ENABLED" == "true" ]] || [[ "$RTSP_HI_RES_ENABLED" == "true" ]]) && [[ "$RTMP_STREAM_ENABLED" == "true" ]] && ([[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]] || [[ "$RTSP_HI_RES_ENABLE_AUDIO" == "true" ]]); then

View File

@ -0,0 +1,158 @@
#!/bin/sh
#Run impdbg commands sequentially
set -x
export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
[ -f $WZMINI_CFG ] && source $WZMINI_CFG
DELAY_BETWEEN=2
RE_RUN_DELAY=5
PARM=1
hi_res_monitor() {
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
if [[ "$RTSP_HI_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
if [ $PARM == 1 ]; then
echo "No Hi-Res imp variables enabled, check Low-Res"
fi
low_res_monitor
else
echo "Hi-Res RTSP not enabled"
low_res_monitor
fi
}
low_res_monitor () {
if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
else
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]]; then
/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
echo "Invalid encoder value"
fi
fi
fi
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
echo "not supported on T20"
else
/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
if [[ "$RTSP_LOW_RES_FPS" != "" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
/system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
else
/system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS
sleep $DELAY_BETWEEN
PARM=$((PARM+1))
fi
fi
if [ $PARM == 1 ]; then
echo "No Low-Res imp variables enabled, exit"
break
fi
else
echo "Low-Res RTSP not enabled"
if [[ "$RTSP_HI_RES_ENABLED" == "true" ]] && [ $PARM -gt 1 ]; then
hi_res_monitor
else
break
fi
fi
}
while true; do
hi_res_monitor
echo "Restart imp_helper.sh, sleep for $RE_RUN_DELAY"
sleep $RE_RUN_DELAY
done