Broadcasting to twitch.tv using ffmpeg
April 13, 2012 in Games, Linux, Software by Raptor85
There wasn’t a whole lot of information about it around but I managed to piece together a quick script to do live streaming from a linux desktop. It’s simple and for speed reasons I’m not broadcasting sound myself. (I get unrealiable levels of upload lag so if i add sound it’s kinda distorted…I really wish their streams allowed speex codec :/)
#!/bin/bash
SIZE="1600x1200"
BITRATE="128k"
FRAMERATE="20"
KEY="your key here"
ffmpeg -f x11grab -s $SIZE -r $FRAMERATE -i :0.0 -vb $BITRATE -vcodec libx264 -threads 0 -f flv "rtmp://live.justin.tv/app/$KEY"
if you do want sound, you can change it to this for alsa
ffmpeg -f x11grab -s $SIZE -r $FRAMERATE -i :0.0 -f alsa -ac 2 -i hw:0,0 -vb $BITRATE -vcodec libx264 -threads 0 -acodec libmp3lame -ab 128k -ar 22050 -f flv "rtmp://live.justin.tv/app/$KEY"
or for OSS
ffmpeg -f x11grab -s $SIZE -r $FRAMERATE -i :0.0 -f oss -i /dev/dsp -vb $BITRATE -vcodec libx264 -threads 0 -acodec libmp3lame -ab 128k -ar 22050 -f flv "rtmp://live.justin.tv/app/$KEY"