Skip to content

Instantly share code, notes, and snippets.

@dominiccooney
Last active August 29, 2015 14:27
Show Gist options
  • Save dominiccooney/de0a3226e57f21ae7634 to your computer and use it in GitHub Desktop.
Save dominiccooney/de0a3226e57f21ae7634 to your computer and use it in GitHub Desktop.
Try livestreaming Ubuntu desktop to YouTube using avconv
#!/bin/bash
# Adapted from http://danielj.se/2012/09/09/how-to-live-stream-your-ubuntu-desktop/
INRES="2560x1440" # input resolution
OUTRES="1920x1080"
OFFSET="0,0"
FPS="15" # target FPS
QUAL="fast" # one of the many FFMPEG preset
URL="rtmp://a.rtmp.youtube.com/live2/${STREAM_KEY:?You need to set STREAM_KEY.}"
avconv -f x11grab -s "$INRES" -r "$FPS" -g $(expr $FPS / 4 + 1) \
-i :0.0+$OFFSET -ab 0k \
-f alsa -ac 2 -i pulse -vcodec libx264 -crf 30 -preset "$QUAL" -s "1920x1080" \
-b 4500k -vol 0 -acodec libmp3lame -ar 44100 -threads 0 \
-f flv "$URL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment