Skip to content

Instantly share code, notes, and snippets.

@pyro2927
Last active December 20, 2015 02:29
Show Gist options
  • Save pyro2927/6056715 to your computer and use it in GitHub Desktop.
Save pyro2927/6056715 to your computer and use it in GitHub Desktop.
Ruby script to load Gravatars for git repo and produce gource video
#!/usr/bin/env ruby
# Run script from inside git repo
# Paths setup for OS X
# requires gource and ffmpeg
# On OS X:
# brew install ffmpeg gource
# Written by: Joe Pintozzi
#
# Resources
# gource: https://code.google.com/p/gource/
# homebrew: http://mxcl.github.io/homebrew/
# pearl gravatar script: https://code.google.com/p/gource/wiki/GravatarExample
require "open-uri"
require "digest/md5"
require "fileutils"
log = %x[git log].split("\n")
FileUtils.mkdir_p '.git/avatars'
emails = Array.new
log.each do |line|
/Author:\s*(.*)\s*<([a-z\.]*@[a-z]*\.[a-z]{2,})>/.match(line) { |m|
newHash = {name: m[1], email: m[2]}
emails << newHash unless m[2].nil? or emails.include?(newHash)
}
end
emails.each do |hash|
puts hash[:name]
File.open('.git/avatars/' + hash[:name].strip! + '.png', 'wb') do |fo|
fo.write open("http://www.gravatar.com/avatar/" + Digest::MD5.hexdigest(hash[:email]) + "?d=404&s=90").read
end
end
# now gource it
%x[gource --hide filenames,dirnames,date --user-image-dir .git/avatars/ -1280x720 -s 1 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 1 -threads 0 -bf 0 ~/Desktop/output.mp4]
# exported video is uncompressed and most likely huge
# shrink it down with
# ffmpeg -i ~/Desktop/output.mp4 -b 512k -acodec copy ~/Desktop/shrunk.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment