Live Coding with ffmpeg and justin.tv

Recently I've been experimenting with operating a live coding stream of my desktop. What this means in practice is that I focus on a single project or set of tasks for an hour or two, while streaming everything I do to my channel on justin.tv.

Here's a boring demonstration:

Watch live video from Live coding with @agentdero on Justin.tv

I'll save my thoughts on how the experiment is going for a later blog post, in this post I just wanted to share the how.

First I use this ~/bin/screenstream script:

#!/bin/sh -xe

INFO=$(xwininfo -frame)

WIN_GEO=$(echo $INFO | grep -oEe 'geometry [0-9]+x[0-9]+' | grep -oEe '[0-9]+x[0-9]+')
WIN_XY=$(echo $INFO | grep -oEe 'Corners:\s+\+[0-9]+\+[0-9]+' | grep -oEe '[0-9]+\+[0-9]+' | sed -e 's/\+/,/' )


ffmpeg -f x11grab -s "$INRES" -r "$FPS" -i :0.0+$WIN_XY \
    -f alsa -ac 2 -i default -vcodec libx264  -s "$OUTRES"  \
    -acodec libmp3lame -ab 128k -ar 44100 -threads 0 \
    -f flv "rtmp://live.justin.tv/app/$API_KEY"

There's a couple important things to mention about this:

That's about all there is too it, I wish I could either take credit for the script or at least attribute it, but I can do neither because I found it on a forum some where and then quickly lost the link. Whoops.

comments powered by Disqus