Skip to content

Instantly share code, notes, and snippets.

@hworld
Created November 7, 2013 17:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hworld/7358531 to your computer and use it in GitHub Desktop.
Save hworld/7358531 to your computer and use it in GitHub Desktop.
Little gist for streaming to Twitch from Linux.
#! /bin/bash
# originally from http://tinyurl.com/twitch-linux from taladan
# www.youtube.com/user/taladan
# script created by brodul
# modified by yours truly: CROS
# You obviously must make sure ffmpeg is installed on your OS.
INRES="1920x1080" # input resolution (The resolution of the program you want to stream!)
OUTRES="1280x720" # Output resolution (The resolution you want your stream to be at)
FPS="15" # target FPS
QUAL="fast"
# one of the many FFMPEG preset on (k)ubuntu found in /usr/share/ffmpeg
# If you have low bandwidth, put the qual preset on 'fast' (upload bandwidth)
# If you have medium bandwidth put it on normal to medium
# Write your key in a file named .twitch_key in your home directory
STREAM_KEY=$(cat ~/.twitch_key) # This is your streamkey generated by jtv/twitch found at: http://www.justin.tv/broadcast/adv_other
ffmpeg \
-f x11grab -s $INRES -r "$FPS" -i :0.0 \
-f alsa -ac 2 -i pulse \
-vcodec libx264 -s $OUTRES -preset $QUAL -pix_fmt yuv420p \
-acodec libmp3lame -ar 44100 -threads 4 -bufsize 512k \
-f flv "rtmp://live.twitch.tv/app/$STREAM_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment