further enhance imp_helper, check variables first, and only set if changed

This commit is contained in:
Alfonso Gamboa 2022-09-30 17:03:12 -07:00
parent b7b1e37854
commit 2fcd3dcee6
3 changed files with 118 additions and 33 deletions

View File

@ -1 +1 @@
Wed Sep 28 05:18:26 PM PDT 2022 Fri Sep 30 05:01:52 PM PDT 2022

View File

@ -11,6 +11,22 @@ export WZMINI_CFG=/opt/wz_mini/wz_mini.conf
DELAY_BETWEEN=2 DELAY_BETWEEN=2
RE_RUN_DELAY=60 RE_RUN_DELAY=60
rm -f /opt/wz_mini/tmp/impdbg.out
impdbg --enc_info > /opt/wz_mini/tmp/impdbg.out
CH0_RC=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep "rcMode =" | sed 's/(.*//' | sed 's,.*\(.\{1\}\)$,\1,')
CH0_TGT_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep TargetBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,')
CH0_MAX_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep MaxBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,')
CH0_FPS=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 0/,/STOP/p' | grep frmRateNum | sed 's/(.*//' | sed 's,.*\(.\{2\}\)$,\1,')
CH1_RC=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep "rcMode =" | sed 's/(.*//' | sed 's,.*\(.\{1\}\)$,\1,')
CH1_TGT_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep TargetBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,')
CH1_MAX_BIT=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep MaxBitRate | sed 's/(.*//' | sed 's,.*\(.\{4\}\)$,\1,')
CH1_FPS=$(cat /opt/wz_mini/tmp/impdbg.out | sed -n '/GROUP 1/,/STOP/p' | grep frmRateNum | sed 's/(.*//' | sed 's,.*\(.\{2\}\)$,\1,')
rm -f /opt/wz_mini/tmp/impdbg.out
hi_res_monitor() { hi_res_monitor() {
if [[ "$RTSP_HI_RES_ENABLED" != "true" ]] ; then if [[ "$RTSP_HI_RES_ENABLED" != "true" ]] ; then
return return
@ -19,15 +35,25 @@ hi_res_monitor() {
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]] ; then if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]] ; then
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then
if [[ $RTSP_HI_RES_ENC_PARAMETER != "$CH0_RC" ]] ; then
echo "Setting RTSP_HI_RES_ENC_PARAMETER T20"
/system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER /system/bin/impdbg --enc_rc_s 0:0:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_HI_RES_ENC_PARAMETER"
fi
else else
echo "Invalid encoder value $RTSP_HI_RES_ENC_PARAMETER" echo "Invalid encoder value $RTSP_HI_RES_ENC_PARAMETER"
fi fi
else else
if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then if [[ $RTSP_HI_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then
if [[ $RTSP_HI_RES_ENC_PARAMETER != "$CH0_RC" ]] ; then
echo "Setting RTSP_HI_RES_ENC_PARAMETER"
/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER /system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_HI_RES_ENC_PARAMETER"
fi
else else
echo "Invalid encoder value $RTSP_HI_RES_ENC_PARAMETER" echo "Invalid encoder value $RTSP_HI_RES_ENC_PARAMETER"
fi fi
@ -36,11 +62,21 @@ hi_res_monitor() {
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]] ; then if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]] ; then
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
if [[ $RTSP_HI_RES_MAX_BITRATE != "$CH0_MAX_BIT" ]] ; then
echo "Setting RTSP_HI_RES_MAX_BITRATE T20"
/system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE /system/bin/impdbg --enc_rc_s 0:28:4:$RTSP_HI_RES_MAX_BITRATE
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else else
echo "No change to RTSP_HI_RES_MAX_BITRATE T20"
fi
else
if [[ $RTSP_HI_RES_MAX_BITRATE != "$CH0_MAX_BIT" ]] ; then
echo "Setting RTSP_HI_RES_MAX_BITRATE"
/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE /system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_MAX_BITRATE
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_HI_RES_MAX_BITRATE"
fi
fi fi
fi fi
@ -48,18 +84,33 @@ hi_res_monitor() {
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
echo "not supported on T20" echo "not supported on T20"
else else
if [[ $RTSP_HI_RES_TARGET_BITRATE != "$CH0_TGT_BIT" ]] ; then
echo "Setting RTSP_HI_RES_TARGET_BITRATE"
/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE /system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_TARGET_BITRATE
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_HI_RES_TARGET_BITRATE"
fi
fi fi
fi fi
if [[ "$RTSP_HI_RES_FPS" != "" ]] ; then if [[ "$RTSP_HI_RES_FPS" != "" ]] ; then
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
if [[ $RTSP_HI_RES_FPS != "$CH0_FPS" ]] ; then
echo "Setting RTSP_HI_RES_FPS T20"
/system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS /system/bin/impdbg --enc_rc_s 0:8:4:$RTSP_HI_RES_FPS
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else else
echo "No change to RTSP_HI_RES_FPS T20"
fi
else
if [[ $RTSP_HI_RES_FPS != "$CH0_FPS" ]] ; then
echo "Setting RTSP_HI_RES_FPS"
/system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS /system/bin/impdbg --enc_rc_s 0:80:4:$RTSP_HI_RES_FPS
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_HI_RES_FPS"
fi
fi fi
fi fi
} }
@ -72,15 +123,25 @@ low_res_monitor () {
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]] ; then if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]] ; then
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then
if [[ $RTSP_LOW_RES_ENC_PARAMETER != "$CH1_RC" ]] ; then
echo "Setting RTSP_LOW_RES_ENC_PARAMETER T20"
/system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER /system/bin/impdbg --enc_rc_s 1:0:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_LOW_RES_ENC_PARAMETER T20"
fi
else else
echo "Invalid encoder value $RTSP_LOW_RES_ENC_PARAMETER" echo "Invalid encoder value $RTSP_LOW_RES_ENC_PARAMETER"
fi fi
else else
if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then if [[ $RTSP_LOW_RES_ENC_PARAMETER =~ "^[0|1|2|4|8]$" ]] ; then
if [[ $RTSP_LOW_RES_ENC_PARAMETER != "$CH1_RC" ]] ; then
echo "Setting RTSP_LOW_RES_ENC_PARAMETER"
/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER /system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_LOW_RES_ENC_PARAMETER"
fi
else else
echo "Invalid encoder value $RTSP_LOW_RES_ENC_PARAMETER" echo "Invalid encoder value $RTSP_LOW_RES_ENC_PARAMETER"
fi fi
@ -89,30 +150,55 @@ low_res_monitor () {
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]] ; then if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]] ; then
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
if [[ $RTSP_LOW_RES_MAX_BITRATE != "$CH1_MAX_BIT" ]] ; then
echo "Setting RTSP_LOW_RES_MAX_BITRATE T20"
/system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE /system/bin/impdbg --enc_rc_s 1:28:4:$RTSP_LOW_RES_MAX_BITRATE
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else else
echo "No change to RTSP_LOW_RES_MAX_BITRATE T20"
fi
else
if [[ $RTSP_LOW_RES_MAX_BITRATE != "$CH1_MAX_BIT" ]] ; then
echo "Setting RTSP_LOW_RES_MAX_BITRATE"
/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE /system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_MAX_BITRATE
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_LOW_RES_MAX_BITRATE"
fi
fi fi
fi fi
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]] ; then if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]] ; then
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
echo "not supported on T20" echo "Not supported on T20"
else else
if [[ $RTSP_LOW_RES_TARGET_BITRATE != "$CH1_TGT_BIT" ]] ; then
echo "Setting RTSP_LOW_RES_TARGET_BITRATE"
/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE /system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_TARGET_BITRATE
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_LOW_RES_TARGET_BITRATE"
fi
fi fi
fi fi
if [[ "$RTSP_LOW_RES_FPS" != "" ]] ; then if [[ "$RTSP_LOW_RES_FPS" != "" ]] ; then
if [ -f /opt/wz_mini/tmp/.T20 ] ; then if [ -f /opt/wz_mini/tmp/.T20 ] ; then
if [[ $RTSP_LOW_RES_FPS != "$CH1_FPS" ]] ; then
echo "Setting RTSP_LOW_RES_FPS T20"
/system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS /system/bin/impdbg --enc_rc_s 1:8:4:$RTSP_LOW_RES_FPS
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else else
echo "No change to RTSP_LOW_RES_FPS T20"
fi
else
if [[ $RTSP_LOW_RES_FPS != "$CH1_FPS" ]] ; then
echo "Setting RTSP_LOW_RES_FPS"
/system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS /system/bin/impdbg --enc_rc_s 1:80:4:$RTSP_LOW_RES_FPS
sleep $DELAY_BETWEEN sleep $DELAY_BETWEEN
else
echo "No change to RTSP_LOW_RES_FPS"
fi
fi fi
fi fi
} }
@ -138,4 +224,3 @@ while true; do
echo "Restart imp_helper.sh, sleep for $RE_RUN_DELAY" echo "Restart imp_helper.sh, sleep for $RE_RUN_DELAY"
sleep $RE_RUN_DELAY sleep $RE_RUN_DELAY
done done

View File

@ -161,9 +161,9 @@ b339aee882a5d1c943ad08e4282ec3fd SD_ROOT/wz_mini/usr/bin/iCamera-dbg
0de553a920d30d1e9d84c9ab4136df0d SD_ROOT/wz_mini/usr/bin/ucamera 0de553a920d30d1e9d84c9ab4136df0d SD_ROOT/wz_mini/usr/bin/ucamera
071b974925501c4b83f2dd546d90febd SD_ROOT/wz_mini/usr/bin/netmon.sh 071b974925501c4b83f2dd546d90febd SD_ROOT/wz_mini/usr/bin/netmon.sh
b10bdd54c56d8d8de2a27336f17285fe SD_ROOT/wz_mini/usr/bin/patch_icamera.sh b10bdd54c56d8d8de2a27336f17285fe SD_ROOT/wz_mini/usr/bin/patch_icamera.sh
3e15a736b79854c35abb7fd4f7207064 SD_ROOT/wz_mini/usr/bin/imp_helper.sh dafffcc1bd1e721d508400686338ceb8 SD_ROOT/wz_mini/usr/bin/imp_helper.sh
580b1b6e91e72b4a4fef7b21d8954403 SD_ROOT/wz_mini/usr/bin/getSensorType 580b1b6e91e72b4a4fef7b21d8954403 SD_ROOT/wz_mini/usr/bin/getSensorType
eb77636bf7d3371faadcd7aefc6d81bb SD_ROOT/wz_mini/usr/bin/app.ver 62d799364407472f608ebe06398b6d96 SD_ROOT/wz_mini/usr/bin/app.ver
4c780f0455481d106d47d89f0ae04ed5 SD_ROOT/wz_mini/lib/uClibc.tar 4c780f0455481d106d47d89f0ae04ed5 SD_ROOT/wz_mini/lib/uClibc.tar
9afeb088e4cbabbe0b04033b560204d0 SD_ROOT/wz_mini/lib/libimp.so 9afeb088e4cbabbe0b04033b560204d0 SD_ROOT/wz_mini/lib/libimp.so
4100755cb6cc6e3b76da20c7e3690e16 SD_ROOT/wz_mini/lib/libalog.so 4100755cb6cc6e3b76da20c7e3690e16 SD_ROOT/wz_mini/lib/libalog.so