Skip to content

Instantly share code, notes, and snippets.

@Tangent128
Created March 23, 2020 00:39
Show Gist options
  • Save Tangent128/a6797e34416159cc6fb271be28d3cc7a to your computer and use it in GitHub Desktop.
Save Tangent128/a6797e34416159cc6fb271be28d3cc7a to your computer and use it in GitHub Desktop.
webmetro streaming scripts
#!/bin/sh
FPS=30
INRES=1680x1050
test "$OUTRES" || OUTRES=672x420
# if this needs to be fixed, you can use `ffmpeg -sources pulse` to list candidates
AUDIO_DEVICE=alsa_output.pci-0000_0b_00.3.analog-stereo.monitor
AUDIO_IN="-thread_queue_size 1024 -f pulse -channels 2 -i $AUDIO_DEVICE"
VIDEO_IN="-thread_queue_size 128 -f x11grab -r $FPS -s $INRES -i :0.0+0,0"
exec ffmetro.sh $AUDIO_IN $VIDEO_IN
#!/bin/sh
test "$LOGLEVEL" || LOGLEVEL=info
test "$OUTRES" || OUTRES=-1:420
test "$URL" || URL="http://wireguard.vpn.host.and.port.here.example.com/live/main"
test "$GOP" || GOP=72
test "$SUBS" && SUBS=",subtitles=$SUBS" || SUBS=""
CODECS="-acodec libopus -vcodec vp8 -threads 4 -deadline good -cpu-used 15 -g $GOP -vb 800k -bufsize 1500k"
FILTER="-vf scale=$OUTRES${SUBS} -ac 2"
BIG_CLUSTERS="-live 1 -cluster_size_limit 10M -cluster_time_limit 10K"
OUTPUT="-f webm $BIG_CLUSTERS -"
OPTS="-loglevel $LOGLEVEL"
ffmpeg $OPTS "$@" $FILTER $CODECS $OUTPUT | webmetro send --throttle "$URL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment