#!/bin/sh

# shellcheck disable=SC2034
SND="-f alsa -thread_queue_size 2048 -i default"
STREAM=${1:-http://phobos.2f30:8090/0.ffm}

if [ "$1" = "-q" ]; then
  ffmpeg -f x11grab -r 5 -s 1440x900 -thread_queue_size 1024 -i :0.0 -an -fflags nobuffer "${STREAM}"
else
  # shellcheck disable=SC2312
  ffmpeg -f x11grab -r 5 -s 1440x900 -thread_queue_size 1024 -i :0.0 \
         -f alsa -ac 1 -thread_queue_size 1024 -i default \
         -af 'highpass=f=200, lowpass=f=2000' \
         -fflags nobuffer "${STREAM}" \
         -af 'highpass=f=200, lowpass=f=2000' \
         -c:v libvpx -b:v 5M -c:a libvorbis webcast-"$(date +%Y%m%d%H%M%S)".webm
fi
