Skip to content

Instantly share code, notes, and snippets.

@lancewalton
Last active January 11, 2018 23:37
Show Gist options
  • Save lancewalton/6b7d60ca15448214e0bb to your computer and use it in GitHub Desktop.
Save lancewalton/6b7d60ca15448214e0bb to your computer and use it in GitHub Desktop.
Produces a video of the evolution of a git repository using gource (see https://code.google.com/p/gource/). Also downloads committers' gravatars to use on the video.
#!/bin/zsh
# For Macs, get gource with HomeBrew:
# brew install gource
# brew install ffmpeg
if (( !($# == 3) ))
then
echo "Usage:"
echo $0 "<gravatar directory> <output file base name> <seconds per day>"
exit 1
fi
gravatar_dir=$1
output_file=$2
seconds_per_day=$3
git log --pretty=format:"%ae|%an" | sort | uniq | while read -r line
do parts=("${(s/|/)line}")
username=$parts[2]
gravatar_file=$gravatar_dir/${username}.jpg
if [[ ! (-f $gravatar_file) ]]
then email=$parts[1]
email_hash=`md5 -qs $email`
curl --output $gravatar_dir/${username}.jpg http://www.gravatar.com/avatar/${email_hash}.jpg
fi
done
gource --user-image-dir $gravatar_dir --seconds-per-day $seconds_per_day --hide filenames,usernames --key -1280x720 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 ${output_file}.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment