go2rtc: update to master version, update alsa config to support dsnooper, add ca-bundle certificate to support tls

This commit is contained in:
Alfonso Gamboa 2023-07-19 15:06:08 -07:00
parent 5df2944af9
commit 2fabba2e38
5 changed files with 3491 additions and 29 deletions

View File

@ -632,3 +632,35 @@ timer.hw {
device $DEV
}
}
## for go2rtc
pcm.loop0 {
type hw
card 0
device 0
subdevice 0
}
pcm.dsnooper0 {
type dsnoop
ipc_key 1024
slave.pcm "loop0"
}
pcm.loop2 {
type hw
card 2
device 0
subdevice 0
}
pcm.dsnooper2 {
type dsnoop
ipc_key 1025
slave.pcm "loop2"
}
pcm.!default {
type plug
slave.pcm "dsnooper0" # or "dsnooper2", depending on which one you want to use by default
}

View File

@ -11,12 +11,14 @@ ffmpeg:
streams:
1080p:
- exec:ffmpeg -fflags +genpts+flush_packets+nobuffer+bitexact -flags +low_delay -thread_queue_size 100 -analyzeduration 50 -probesize 50 -pix_fmt yuv420p -r 30 -i /dev/video1 -flags +global_header -movflags +empty_moov+default_base_moof+frag_keyframe -framerate 30 -video_size 1920x1080 -pix_fmt yuv420p -c:v copy -copyts -rtsp_transport tcp -f rtsp {output}
- exec:ffmpeg -hide_banner -f alsa -ac 1 -i hw:0,0 -c:a libopus -filter:a volume=5 -movflags +empty_moov+default_base_moof+frag_keyframe -muxdelay 0 -muxpreload 0 -ac:a 1 -af adelay=0|0 -f rtsp {output}
#Uncomment to enable AAC audio
# - exec:ffmpeg -hide_banner -f alsa -ac 1 -i hw:0,0 -c:a aac -filter:a volume=5 -movflags +empty_moov+default_base_moof+frag_keyframe -muxdelay 0 -muxpreload 0 -ac:a 1 -f rtsp {output}
- exec:ffmpeg -hide_banner -f alsa -ac 1 -i dsnooper0 -c:a copy -muxdelay 0 -muxpreload 0 -f rtsp {output}
- exec:ffmpeg -hide_banner -f alsa -ac 1 -i dsnooper0 -c:a libfdk_aac -afterburner 1 -channels 1 -b:a 128k -profile:a aac_he -ar 16000 -strict experimental -muxdelay 0 -muxpreload 0 -ac:a 1 -f rtsp {output}
# libopus has higher cpu requirements, audio may studder.
# - exec:ffmpeg -hide_banner -f alsa -ac 1 -i dsnooper0 -c:a libopus -muxdelay 0 -muxpreload 0 -ac:a 1 -af adelay=0|0 -f rtsp {output}
360p:
- exec:ffmpeg -fflags +genpts+flush_packets+nobuffer+bitexact -flags +low_delay -thread_queue_size 100 -analyzeduration 50 -probesize 50 -pix_fmt yuv420p -r 30 -i /dev/video2 -framerate 30 -video_size 640x360 -pix_fmt yuv420p -c:v copy -copyts -rtsp_transport tcp -f rtsp {output}
- exec:ffmpeg -hide_banner -f alsa -ac 1 -i hw:2,0 -c:a libopus -filter:a volume=5 -movflags +empty_moov+default_base_moof+frag_keyframe -muxdelay 0 -muxpreload 0 -ac:a 1 -af adelay=0|0 -f rtsp {output}
#Uncomment to enable AAC audio
# - exec:ffmpeg -hide_banner -f alsa -ac 1 -i hw:2,0 -c:a aac -filter:a volume=5 -movflags +empty_moov+default_base_moof+frag_keyframe -muxdelay 0 -muxpreload 0 -ac:a 1 -f rtsp {output}
- exec:ffmpeg -hide_banner -f alsa -ac 1 -i dsnooper2 -c:a copy -muxdelay 0 -muxpreload 0 -ac:a 1 -f rtsp {output}
- exec:ffmpeg -hide_banner -f alsa -ac 1 -i dsnooper2 -c:a libfdk_aac -afterburner 1 -channels 1 -b:a 128k -profile:a aac_he -ar 16000 -strict experimental -muxdelay 0 -muxpreload 0 -ac:a 1 -f rtsp {output}
# libopus has higher cpu requirements, audio may studder.
# - exec:ffmpeg -hide_banner -f alsa -ac 1 -i dsnooper2 -c:a libopus -muxdelay 0 -muxpreload 0 -ac:a 1 -af adelay=0|0 -f rtsp {output}

View File

@ -22,27 +22,21 @@ touch -- "$GO2RTC".log
case "$1" in
start)
echo "#####$(basename "$0")#####"
if [[ "$GO2RTC_SERVER_ENABLED" == "true" ]]; then
if [[ "$GO2RTC_SERVER_ENABLED" == "true" ]]; then
echo "go2rtc enabled"
else
echo "go2rtc disabled"
exit 0
fi
if [[ "$GO2RTC_HI_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
HI_VIDEO_DEV="/dev/video6"
else
HI_VIDEO_DEV="/dev/video1"
fi
echo "Enable video ch 0"
/opt/wz_mini/bin/cmd video 0 on > /dev/null
if [[ "$GO2RTC_HI_RES_ENABLE_AUDIO" == "true" ]]; then
echo "Enable audio ch 0"
/opt/wz_mini/bin/cmd audio 0 on > /dev/null
@ -53,24 +47,17 @@ case "$1" in
DEVICE1="$HI_VIDEO_DEV"
echo "go2rtc hi_res audio disabled"
fi
else
echo "go2rtc hi_res disabled"
fi
if [[ "$GO2RTC_LOW_RES_ENABLED" == "true" ]]; then
if [ -f /opt/wz_mini/tmp/.T20 ]; then
LOW_VIDEO_DEV="/dev/video7"
else
LOW_VIDEO_DEV="/dev/video2"
fi
echo "Enable video ch 1"
/opt/wz_mini/bin/cmd video 1 on > /dev/null
if [[ "$GO2RTC_LOW_RES_ENABLE_AUDIO" == "true" ]]; then
echo "Enable video ch 1"
/opt/wz_mini/bin/cmd audio 1 on > /dev/null
@ -81,27 +68,38 @@ case "$1" in
DEVICE2="$LOW_VIDEO_DEV"
echo "go2rtc low_res audio disabled"
fi
else
echo "go2rtc low_res disabled"
fi
if [[ "$GO2RTC_LOW_RES_ENABLED" == "true" ]] || [[ "$GO2RTC_HI_RES_ENABLED" == "true" ]]; then
echo "delay go2rtc for iCamera"
#This delay is required. Sometimes, if you start the go2rtc server too soon, live view will break on the app.
sleep 5
export ALSA_CONFIG_PATH=/opt/wz_mini/etc/alsa/alsa.conf
export ALSA_CONFIG_PATH=/opt/wz_mini/etc/alsa/alsa.conf
/opt/wz_mini/bin/go2rtc_linux_mipsel -config /opt/wz_mini/etc/go2rtc.yml > $GO2RTC.log 2>&1 &
attempts=0
while true; do
SSL_CERT_FILE=/opt/wz_mini/etc/ssl/ca-bundle.crt /opt/wz_mini/bin/go2rtc_linux_mipsel -config /opt/wz_mini/etc/go2rtc.yml > $GO2RTC.log 2>&1 &
pid=$!
wait $pid
exit_status=$?
if [ $exit_status -eq 0 ]; then
break
else
echo "Process exited unexpectedly, restarting."
let "attempts+=1"
if [ $attempts -ge 20 ]; then
echo "Process exited unexpectedly too many times. Not restarting."
break
fi
fi
done & # run the loop in background
fi
sync;echo 3 > /proc/sys/vm/drop_caches
;;
stop)
pkill go2rtc_linux_mipsel
pkill -f "/bin/sh /opt/wz_mini/bin/go2rtc_linux_mipsel"
cmd video 0 off
cmd audio 0 off
cmd video 1 off
@ -116,4 +114,3 @@ case "$1" in
exit 1
;;
esac

File diff suppressed because it is too large Load Diff