#!/bin/sh
INRES=1680x1050
test "$FPS" || FPS=29.97
test "$OUTRES" || OUTRES=672x420
test "$URL" || URL="http://127.0.0.1:2509/live/purrloin"
test "$GOP" || GOP=120
AUDIO_IN="-thread_queue_size 1024 -f dshow -channels 2 "
VIDEO_IN="-thread_queue_size 128 -f gdigrab -framerate $FPS -i desktop"
FILTER="-vf fps=$FPS -af aresample=async=1000 -s $OUTRES -ac 2"
CODECS="-acodec libopus -vcodec vp8 -g $GOP"
BIG_CLUSTERS="-live 1 -cluster_size_limit 10M -cluster_time_limit 10K"
OUTPUT="-f webm $BIG_CLUSTERS"
AUDIO_IN="$AUDIO_IN -i audio=\"Stereo Mix (Realtek High Definition Audio)\""
ffmpeg $AUDIO_IN $VIDEO_IN $FILTER $CODECS $OUTPUT "$URL"