X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=ffs;h=0570787709847c971e649a40b2612f88dca1b926;hb=87c3f2244a47ad10a031a27d0d0456f0a7defd21;hp=9efc9f0ebc75e454a076cd01bfa047200632b027;hpb=8de1e14e35d0ad62620a59f6e2ca4ba19ddcda3c;p=distro-setup diff --git a/ffs b/ffs index 9efc9f0..0570787 100755 --- a/ffs +++ b/ffs @@ -143,12 +143,22 @@ fi ##### end command line parsing ######## -host=live.iankelling.org:443 -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) @@ -176,11 +186,18 @@ else stream_res=$primary_res fi -# 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). +stream_x=${stream_res%x*} +stream_y=${stream_res#*x} + +# leave out our i3 window borders +stream_res=$(( stream_x - 4 ))x$(( stream_y - 4)) -bitrate=$(( ( ${stream_res/x/*} ) / 1380 )) + +# 1000 is a bit blury, 1500 is pretty clear +# note https://livekit.io/webrtc/bitrate-guide (our framerate is lower) + +# Scale our bitrate to 1500 1080p +bitrate=$(( ( stream_x * stream_y ) / ( (1920*1080) / 1000 ) )) # 8 seems fine. be conservative by going a bit higher. framerate=10 @@ -296,7 +313,7 @@ if pkill -f ^ffmpeg.\*icecast://source.\*/fsf; then sleep 1 fi -#echo executing: ffmpeg ${opts[@]} +echo executing: ffmpeg ${opts[@]} #{ sleep 1; ffp &>/dev/null & } @@ -360,8 +377,6 @@ if $watch; then rm -f $HOME/.iank-stream-on fi - - ### begin background/development docs ### # zmq vs stdin commands: @@ -447,4 +462,9 @@ fi # ./configure --enable-libzmq --enable-libpulse --enable-libvorbis --enable-gpl --enable-version3 # +# note: when playing back, text is going to look aliased unless you +# watch it in a window that is exactly as bit or bigger than the +# recording: tabbed i3 window shrinks things. or, use: mpv +# --video-unscaled + ### end background/development docs ###