Skip to content

Instantly share code, notes, and snippets.

@brodul
Created July 25, 2012 19:38
Show Gist options
  • Save brodul/3178114 to your computer and use it in GitHub Desktop.
Save brodul/3178114 to your computer and use it in GitHub Desktop.
Twitch.tv script for streaming
#! /bin/bash
# originaly from http://tinyurl.com/twitch-linux from taladan
# www.youtube.com/user/taladan
# gist created by brodul
INRES="1280x800" # input resolution
#OUTRES="1024x640" # Output resolution
OUTRES="800x500" # Output resolution
FPS="30" # target FPS
QUAL="medium" # 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 bandwitch 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
avconv \
-f x11grab -s $INRES -r "$FPS" -i :0.0 \
-f alsa -ac 2 -i pulse \
-vcodec libx264 -s $OUTRES -preset $QUAL \
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b 712000 -bufsize 512k \
-f flv "rtmp://live.justin.tv/app/$STREAM_KEY"
@iancustoica
Copy link

Hi,

Thanks for this script - I am trying to run it on ubuntu 13.04 but having some problems.

Here's the config:
INRES=”1280x720″ # input resolution
OUTRES=”1280x720″ # Output resolution
FPS=”25″ # target FPS
QUAL=”ultrafast”
STREAM_KEY=$(cat ~/twitch/.twitch_key)

avconv
-f x11grab -s $INRES -r “$FPS” -i :0.0
-f alsa -ac 2 -i pulse
-vcodec libx264 -s $OUTRES -preset $QUAL
-acodec libmp3lame -ar 44100 -threads 6 -qscale 3 -b 712000 -bufsize 512k
-f flv “rtmp://live.twitch.tv/app/$STREAM_KEY”

and here's the error message:
[x11grab @ 0x1215d00] Couldn't parse video size.
:0.0: Invalid argument

Do you have any idea why I am getting this error?

Best regards,
Iancul

@SwooshyCueb
Copy link

Look like the quotes are directional quotes. Go back and retype every quotation mark and it should work.

Copy link

ghost commented Jan 20, 2018

Bumping this thread to mention that I'm having issues:

  1. Terminal window runs fine and prints frame outputs but stream doesn't start
  2. If stream does start (sometimes it works), I only see a green screen with static.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment