Saturday, May 29, 2010

How to Set Up Gource in Ubuntu 10.04


Gource is an amazing open source project that creates visualizations of the development history of any software project that use a version control system such as Mercurial or Git. With this tool, you can analyze how your code grows over time, see how developers are interacting with the code base, and also understand how your code tree looks. While Gource is fantastic, getting it to run in Ubuntu 10.04 takes a bit of work so this guide will show you exactly how to install and run Gource.

Gource Setup Steps in Ubuntu:

1) Install the necessary libraries to build Gource:
sudo apt-get install build-essential libsdl1.2-dev libsdl-image1.2-dev libftgl-dev libpcre3-dev libpng12-dev libjpeg62-dev

2) Download the latest Gource and unpack:
tar xzf gource-0.26b.tar.gz

3) Configure, make, and install Gource:
cd gource-0.26b
sudo make install

4) Run Gource on your Mercurial/Git repository:
cd [path_to_root_of_repository]
gource --seconds-per-day 80 --auto-skip-seconds 0.1 --file-idle-time 500 --max-files 500 --multi-sampling -1280x720 --stop-at-end --elasticity 0.1 -b 000000  --hide filenames,dirnames  --disable-progress --user-friction .2 --disable-bloom

Hopefully, you will see Gource animate all your commit history!

5) Tweak settings to achieve the desired effects and output:
man gource

Depending on the size of your project, you will need to adjust the --seconds-per-day attribute in order to get the right timing of the video.

Steps to Record Video:

Once you have Gource working, you probably want to create videos of this and upload it to YouTube. Here is how you can do that in Ubuntu 10.04.

1) Set up video encoding:

Follow the instructions to get x264 encoding working in your installation:

Here are the steps below in case ubuntuforum goes down:

Install dependencies
sudo apt-get remove ffmpeg x264 libx264-dev
sudo apt-get update
sudo apt-get install build-essential subversion git-core checkinstall yasm texi2html libfaac-dev libfaad-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libvorbis-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev

Build and install x254
git clone git://
cd x264
sudo checkinstall --pkgname=x264 --pkgversion "2:0.`grep X264_BUILD x264.h -m1 | cut -d' ' -f3`.`git rev-list HEAD | wc -l`+git`git rev-list HEAD -n 1 | head -c 7`" --backup=no --default

Build and install FFmpeg
svn checkout svn:// ffmpeg
cd ffmpeg
./configure --enable-gpl --enable-version3 --enable-nonfree --enable-postproc --enable-pthreads --enable-libfaac --enable-libfaad --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-x11grab
sudo checkinstall --pkgname=ffmpeg --pkgversion "4:SVN-r`svn info | grep Revision | awk '{ print $NF }'`" --backup=no --default
hash x264 ffmpeg

2) Record your Gource video:
gource --seconds-per-day 80 --auto-skip-seconds 0.1 --file-idle-time 500 --max-files 500 --multi-sampling -1280x720 --stop-at-end --elasticity 0.1 -b 000000  --hide filenames,dirnames  --disable-progress --user-friction .2 --disable-bloom --output-ppm-stream - | ffmpeg -an -threads 4 -y -vb 4000000 -aspect 16:9 -r 60  -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre hq gource.mp4

3) View your video:
mplayer gource.mp4

4) Upload your video to YouTube!


My project is very small right now so my video is not very impressive but the Gource technology and concept certainly is. With the few steps outlined in this guide, you should be able to get Gource running on your own projects. The effort is well worth it and it adds a cool new dimension into how you look at code.



  1. gource --seconds-per-day 80 --auto-skip-seconds 0.1 --file-idle-time 500 --max-files 500 --multi-sampling -1280x720 --stop-at-end --elasticity 0.1 -b 000000  --hide filenames,dirnames  --disable-progress --user-friction .2 --disable-bloom --output-ppm-stream - | ffmpeg -an -threads 4 -y -vb 4000000 -aspect 16:9 -r 60  -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre hq gource.mp4
    ffmpeg version 0.8.3-4:0.8.3-0ubuntu0.12.04.1, Copyright (c) 2000-2012 the Libav developers
    built on Jun 12 2012 16:52:09 with gcc 4.6.3
    This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
    Unable to find a suitable output format for ' -f'
    gource: unsupported log format (you may need to regenerate your log file)
    Try 'gource --help' for more information.

  2. I executed following command but there output file created is of 4k only, means no data.

    gource --seconds-per-day 80 --auto-skip-seconds 0.1 --file-idle-time 500 --max-files 500 -1280x720 --stop-at-end --elasticity 0.1 -b 000000 --hide filenames,dirnames --disable-progress --user-friction .2 --disable-bloom --output-ppm-stream - | ffmpeg -an -threads 4 -y -vb 4000000 -aspect 16:9 -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre hq gource.mp4
    FFmpeg version 0.6.5, Copyright (c) 2000-2010 the FFmpeg developers
    built on Jan 29 2012 17:53:48 with gcc 4.4.5 20110214 (Red Hat 4.4.5-6)
    configuration: --prefix=/usr --libdir=/usr/lib --shlibdir=/usr/lib --mandir=/usr/share/man --incdir=/usr/include --disable-avisynth --extra-cflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i686 -mtune=atom -fasynchronous-unwind-tables' --enable-avfilter --enable-avfilter-lavf --enable-libdc1394 --enable-libdirac --enable-libfaac --enable-libfaad --enable-libfaadbin --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-librtmp --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libx264 --enable-gpl --enable-nonfree --enable-postproc --enable-pthreads --enable-shared --enable-swscale --enable-vdpau --enable-version3 --enable-x11grab
    libavutil 50.15. 1 / 50.15. 1
    libavcodec 52.72. 2 / 52.72. 2
    libavformat 52.64. 2 / 52.64. 2
    libavdevice 52. 2. 0 / 52. 2. 0
    libavfilter 1.19. 0 / 1.19. 0
    libswscale 0.11. 0 / 0.11. 0
    libpostproc 51. 2. 0 / 51. 2. 0
    [image2pipe @ 0x940e930]Estimating duration from bitrate, this may be inaccurate
    Input #0, image2pipe, from 'pipe:':
    Duration: N/A, bitrate: N/A
    Stream #0.0: Video: ppm, rgb24, 1280x720, 60 tbr, 60 tbn, 60 tbc
    [libx264 @ 0x9434ff0]using cpu capabilities: MMX2 SSE2Fast SSSE3 FastShuffle SSE4.2
    [libx264 @ 0x9434ff0]profile High, level 3.2
    [libx264 @ 0x9434ff0]264 - core 107 - H.264/MPEG-4 AVC codec - Copyleft 2003-2010 - - options: cabac=1 ref=4 deblock=1:0:0 analyse=0x3:0x113 me=umh subme=8 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=4 sliced_threads=0 nr=0 decimate=1 interlaced=0 constrained_intra=0 bframes=3 b_pyramid=0 b_adapt=2 b_bias=0 direct=3 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=4000 ratetol=1.0 qcomp=0.60 qpmin=10 qpmax=51 qpstep=4 ip_ratio=1.41 aq=1:1.00
    Output #0, mp4, to 'gource.mp4':
    encoder : Lavf52.64.2
    Stream #0.0: Video: libx264, yuv420p, 1280x720, q=10-51, 4000 kb/s, 60 tbn, 60 tbc
    Stream mapping:
    Stream #0.0 -> #0.0
    frame= 1 fps= 0 q=0.0 Lsize= 0kB time=10000000000.00 bitrate= 0.0kbits/s
    video:0kB audio:0kB global headers:0kB muxing overhead 602.702703%
    [libx264 @ 0x9434ff0]final ratefactor: 23.94

  3. great tutorial.
    Update to 12.04...
    ./configure failed a few times
    I had to search for SDL_image and boost.

    sudo apt-get install libsdl-image1.2-dev
    sudo apt-get install libboost-all-dev
    sudo apt-get install libglm-dev
    (warning, libbost is HUGE)

    the ubuntuforums x264 thread was also blocking me with permissions errors, so thanks for posting that too.