Skip to content

Instantly share code, notes, and snippets.

@mrrooijen
Created November 6, 2012 17:33
Show Gist options
  • Select an option

  • Save mrrooijen/4026219 to your computer and use it in GitHub Desktop.

Select an option

Save mrrooijen/4026219 to your computer and use it in GitHub Desktop.
[Linux] Screen Recording / Streaming Command-Line Utilities.
#!/bin/sh
# For pulse users:
# Don't forget to set "Monitor of Built-in..." in "Recording" tab in pavucontrol
INRES="1680x1050"
OUTRES="1280x800"
FPS="30"
OFFSET="0.0+1280,0"
VOLUME_LEVEL="128"
QUAL="veryfast"
OUT="out.flv"
nice -n 10 ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :"$OFFSET" \
  -f alsa -ac 2 -i pulse -vol "$VOLUME_LEVEL" \
  -vcodec libx264 -s "$OUTRES" -profile baseline -preset "$QUAL" \
  -acodec libmp3lame -ab 96k -ar 44100 \
  -threads 0 \
  -f flv "$OUT"
INRES="1680x1050"                                            # 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+1680 \
   -f alsa -ac 2 -i pulse  \
   -vcodec libx264 -s $OUTRES -preset $QUAL \
   -acodec libmp3lame -ar 44100 -threads 3 -qscale 3 -b 712000  -bufsize 512k \
   -f flv "rtmp://live.justin.tv/app/$STREAM_KEY"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment