Skip to content

Instantly share code, notes, and snippets.

@dbrownidau
Last active February 9, 2016 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbrownidau/26d2327b38d10a079e15 to your computer and use it in GitHub Desktop.
Save dbrownidau/26d2327b38d10a079e15 to your computer and use it in GitHub Desktop.
Linux stream to youtube via libav. (for distributions utilizing Aptitude)
#! /bin/bash
INRES="1366x768"
OUTRES="1366x768"
VBR="1800k"
FPS="30" # fps
QUAL="slow"
STREAM_KEY=$(cat ~/bin/youtube_key)
if [ $(dpkg-query -W -f='${Status}' libav-tools 2>/dev/null | grep -c "ok installed") -eq 0 ];
then
echo "Need to install libav-tools."
sudo apt-get update;
sudo apt-get install -y libav-tools;
fi
avconv \
-f x11grab -s $INRES -r "$FPS" -i :0.0 \
-f alsa -ac 2 -i pulse \
-vcodec libx264 -pix_fmt yuv420p -preset $QUAL -r $FPS -g $(($FPS * 2)) -b:v $VBR \
-acodec libmp3lame -ar 44100 -threads 4 -qscale 3 -b:a 712000 -bufsize 512k \
-f flv "rtmp://a.rtmp.youtube.com/live2/$STREAM_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment