+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))
+
+
+# if hardware acceleration exists, use it to save power & cpu.
+if vainfo |& grep -i VAProfileVP9Profile &>/dev/null; then
+ # 1500 seems almost flawless
+ bitrate_1080=1500
+
+ encode_settings=(
+ -c:v vp9_vaapi
+ # these options increase compression based on random internet reference.
+ -bsf:v vp9_raw_reorder,vp9_superframe
+ )
+ # https://trac.ffmpeg.org/wiki/Hardware/VAAPI
+ global_extra_args=(
+ -vaapi_device /dev/dri/renderD128
+ )
+ extra_filter_arg=",format=nv12|vaapi,hwupload"
+else
+ # 1000 is a bit blury, 1500 is pretty clear, 2000 makes scrolling
+ # adjust much faster, 2500 has marginal improvement on that.
+ #
+ # note https://livekit.io/webrtc/bitrate-guide (our framerate is lower)
+ bitrate_1080=2000
+
+ encode_settings=(
+ -vcodec libvpx
+ -quality realtime
+ -error-resilient 1
+ )
+fi
+
+bitrate=$(( ( stream_x * stream_y ) / ( (1920*1080) / bitrate_1080 ) ))
+
+
+# 8 seems fine. be conservative by going a bit higher.
+framerate=10