Skip to content

Instantly share code, notes, and snippets.

@digitalresistor
Created February 11, 2012 04:18
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digitalresistor/1796116 to your computer and use it in GitHub Desktop.
Save digitalresistor/1796116 to your computer and use it in GitHub Desktop.
Generates various mpeg4 files from a gource run ...

Collection of Gource Helper Scripts

This collection of helper scripts are used to generate .mp4 files containing the output from gource, a visualisation tool that generates pretty output from the git log output.

Requirements

  1. gource
  2. ffmpeg with x264 support
  3. tmux (not required)

Setup

Move the four scripts into your local bin directory:

mkdir ~/bin/
# move scripts to ~/bin/
chmod +x ~/bin/gource-*.sh

First create a new directory where you are going to store your various repositories:

mkdir ~/repos

Then clone all of the repo's you want to run gource on into that directory:

cd ~/repos
git clone git://...

After this is completed, modify run-all.sh to point to the correct directories or run gource-run.sh directly.

~/bin/gource-run.sh ~/repos ~/gource-output

Now the script will first combine the log output from each of the repos and write a combined.mp4. This basically shows everything that has been done in one huge chart for all of the different repositories, if you would prefer not to do that feel free to remove those lines from gource-run.sh.

After it finishes chugging through the generation of the videos it will let you know. At which point you can upload them to your favourite video sharing website.

run-all.sh

run-all.sh is a small script that uses Xvfb (X virtual frame buffer) and tmux to run the scripts on a head-less server. Please be aware that the X server runs without auth required, so anyone could connect to it and run X11 applications on it. This will be slower than having a graphics card that does OpenGL, as would be expected.

run-all.sh takes care of either creating a new tmux session, or if one already exists it will simply attach the new windows to it. It is safe to run run-all.sh multiple times, it won't cause the script to be killed or otherwise canceled. For exmaple, I am currently running it from cron late at night when nobody is at the office.

#!/usr/bin/env sh
# $1 directory contantaining git sub-directories
# $2 output file
for GITREPODIR in $1/*; do
if [ -d $GITREPODIR ];
then
if [ ! -d $GITREPODIR/.git ];
then
continue
fi
NAME=`basename $GITREPODIR`
echo Generating logs for: $NAME from $GITREPODIR
(cd $GITREPODIR; git pull) 2>&1 1>/dev/null
`dirname $0`/gource-log.sh $GITREPODIR $NAME >> $2.tmp
fi
done
echo "Sorting output file"
sort -u --output=$2 $2.tmp
rm -f $2.tmp
echo "Sorted."
#!/usr/bin/env sh
# $1 is path to git directory
# $2 is project name
gource --output-custom-log - --path $1 | sed -E "s/\|([^|]+)$/\|\/$2\1/"
#!/usr/bin/env sh
# $1 path to repositories
# $2 path to output
LOCATION=`dirname $0`
gource_custom()
{
gource -1280x720 -a 0.1 -s 0.5 --key --colour-images -r 30 --highlight-users --log-format custom --highlight-dirs --path $1 -r 30 -o - | ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -crf 1 -threads 0 -b 0 $2
}
gource_path()
{
gource -1280x720 -a 0.2 -s 1 --key --colour-images -r 30 --highlight-users --highlight-dirs --path $1 -r 30 -o - | ffmpeg -y -r 30 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -crf 1 -threads 0 -b 0 $2
}
if [ $# -ne 2 ];
then
echo "Not enough parameters."
exit 1
fi
if [ ! -d $1 ];
then
echo "Path to repositories is not a directory ..."
exit 2
fi
if [ ! -d $2 ];
then
echo "Output directory does not exist. Creating"
mkdir $2
if [ ! -d $2 ];
then
echo "Output directory still does not exist. Error!"
exit 3
fi
fi
echo Creating multiple repositories output
$LOCATION/gource-genmulti.sh $1 $2/combined.gource
echo Running gource and outputting to $2/combined.mp4
gource_custom $2/combined.gource $2/combined.mp4
echo Completed combined video
echo Creating individual repositories
for GITREPODIR in $1/*; do
if [ -d $GITREPODIR ];
then
if [ ! -d $GITREPODIR/.git ];
then
continue
fi
NAME=`basename $GITREPODIR`
echo Running gource and outputting to $2/$NAME.mp4
gource_path $GITREPODIR $2/$NAME.mp4
fi
done
echo Completed all repositories
#!/usr/bin/env sh
cd ~gource
tmux has-session -t "gource"
if [ $? -eq 0 ];
then
echo Attaching to current session
else
tmux new-session -d -s "gource" "tcsh"
tmux new-window -d -t gource:1 "Xvfb $DISPLAY -screen 0 1280x720x24 -ac"
fi
tmux new-window -d -t gource:2 "./bin/gource-run.sh ./repositories/ ./output/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment