Source Code Visualization with Gource

http://michaeldehaan.net/2010/01/15/source-code-visualization-with-gource/

Gource is an amazing program for visualizing commit history in a git-based code project. What I like about it is that it can also show what areas of the project are active in an easy to understand way, to show whether there is community around a whole project or just aspects of it. What looks like a shiny useless visualization is, in fact, pretty useful stuff. I’ll get to that in a bit.

So, I needed something to scan and past OSS things I’ve been involved with were logical first targets. To index the history on Cobbler into a concise video, I ran the following:

gource -s 0.03 --auto-skip-seconds 0.1 --file-idle-time 500 --max-files
500 --multi-sampling -1280x720 --stop-at-end   --output-ppm-stream - |
    ffmpeg -y -b 3000K -r 24 -f image2pipe -vcodec ppm -i - -vcodec mpeg4
    gource.mp4

Want to run this yourself? You will likely have to build gource from source. I’ll warn you that building from source involves installing a ton of deps, though all are in Ubuntu 9.10, and once ./configure finally passes it does build fast. Fedora was downlevel with respect to ftgl, and compiling ftgl from source was difficult, hence the Ubuntu usage. The parameters I use above result in a large video (75MB) but are intended for YouTube HD.

The result is below. Note that I didn’t keep my source control commit attribution for the first couple of years on the project (lesson learned in how to use git!), I used to do development on devel and switched to master (this video shows master), and koan was grafted into the cobbler tree late in the game. Early on, I committed from two different user IDs. As a result, the video is not perfect — things tend to “pop” into view as releases happen. You’ll see the first outside attribution happen about 1/2 way through, though of course this was happening much much earlier. Still, the acceleration at the end, I think, means we achieved something pretty decent. Not all projects do.

Perhaps this is a start of a good meme. Get your code up on YouTube. Show us the life of your code and who you collaborate with.

Recording Videos

You can create a video of Gource using the --output-ppm-stream option. This creates an uncompressed sequence of screenshots in PPM format which can then be processed by another program (such as ffmpeg) to produce a video. The below command line will create a video at 60fps in x264 format (assumes you have ffmpeg with x264 support):

gource --disable-progress --stop-at-end --output-ppm-stream - | ffmpeg -y -b
3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 gource.mp4

You can also adjust the output frame rate with --output-framerate. Note you will need to adjust the frame rate used by the encoder (eg ffmpeg -r) as well.

Note: You may need to add '-vpre default' to the ffmpeg command. The exact arguments to ffmpeg may vary depending on the version you have. There is a good guide to using x264 with ffmpeg here.