X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=ffs;h=d63668b6e45b3736e479b37ba1851f32351b9df4;hb=989554cab0d0c59d1aab20496ba9550acd17e6e6;hp=fe42908750b636051efe1ba9d2393b89d95f94e3;hpb=55b37c2dbe292fa1023c0c5376c2104fbe568011;p=distro-setup diff --git a/ffs b/ffs index fe42908..d63668b 100755 --- a/ffs +++ b/ffs @@ -22,12 +22,9 @@ # ffs = ffmpeg stream -# todo: learn to start working in one corner of the screen. - -# potential improvement: it might be nice that we could have a tall terminal bug only use +# potential improvement: it might be nice that we could have a tall terminal but only use # the top half for a 1080p stream, this is how: # https://superuser.com/questions/1106674/how-to-add-blank-lines-above-the-bottom-in-terminal -# if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi @@ -146,12 +143,22 @@ fi ##### end command line parsing ######## -host=live.iankelling.org:8000 -if ip n show 10.2.0.1 | grep . &>/dev/null && \ - [[ $(dig +timeout=1 +short @10.2.0.1 -x 10.2.0.2 2>&1 ||:) == kd.b8.nz. ]]; then +host=live.iankelling.org:8443 +live_host=$(dig +timeout=1 +short @iankelling.org live.iankelling.org) +vps_host=$(dig +timeout=1 +short iankelling.org) +if [[ $live_host != "$vps_host" ]] && ip n show 10.2.0.1 | grep . &>/dev/null && \ + [[ $(dig +timeout=1 +short @10.2.0.1 -x 10.2.0.2 2>&1 ||:) == kd.b8.nz. ]]; then host=127.0.0.1:8000 +else + find_prefix="ssh live.iankelling.org" +fi + +if $find_prefix find /var/icecast -type f | grep .; then + echo "warning: suggest clearing /var/icecast with icrmr or moving files. sleeping for 4 seconds" + sleep 4 fi + pass=$(sed -n 's/ *\([^<]*\).*/\1/p' /p/c/icecast.xml) @@ -179,7 +186,14 @@ else stream_res=$primary_res fi -framerate=8 +# for 1080p, default 256k is poor quality. 500 is ok. 1500 is a bit +# better, so go with that. Also, that is about 2x what is recommended +# in https://livekit.io/webrtc/bitrate-guide (our framerate is lower). + +bitrate=$(( ( ${stream_res/x/*} ) / 1380 )) + +# 8 seems fine. be conservative by going a bit higher. +framerate=10 keyframe_interval=$((framerate * 2)) # Monitor of default sink. @@ -266,8 +280,7 @@ opts=( -vcodec libvpx -g $keyframe_interval -quality realtime - # for 1080p, default 256k is poor quality. 500 is ok. 1500 is a bit better. - -b:v 1500k + -b:v ${bitrate}k -threads 2 -error-resilient 1 @@ -357,8 +370,6 @@ if $watch; then rm -f $HOME/.iank-stream-on fi - - ### begin background/development docs ### # zmq vs stdin commands: