Skip to content

Instantly share code, notes, and snippets.

@viktorkelemen
Created July 10, 2012 08:35
Show Gist options
  • Select an option

  • Save viktorkelemen/3082055 to your computer and use it in GitHub Desktop.

Select an option

Save viktorkelemen/3082055 to your computer and use it in GitHub Desktop.
Gource with ffmpeg
gource -1280x720 --seconds-per-day 0.1 --key --hide dirnames, -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -crf 1 -threads 0 -bf 0 output.mp4
@bookmytripm

Copy link
Copy Markdown

#!/usr/bin/env bash

gource-export.sh

Generates an MP4 "code growth" video from any git repo's history using Gource.

USAGE:

./gource-export.sh /path/to/repo [output_name.mp4]

REQUIREMENTS (install once):

sudo apt update && sudo apt install -y gource ffmpeg

EXAMPLES:

./gource-export.sh ~/projects/mfic-hub

./gource-export.sh ~/projects/kwathu-app kwathu_growth.mp4

set -euo pipefail

REPO_PATH="${1:-}"
OUTPUT="${2:-gource_output.mp4}"

if [ -z "$REPO_PATH" ]; then
echo "Usage: $0 /path/to/repo [output_name.mp4]"
exit 1
fi

if [ ! -d "$REPO_PATH/.git" ]; then
echo "Error: '$REPO_PATH' does not look like a git repository (.git folder not found)."
exit 1
fi

if ! command -v gource >/dev/null 2>&1; then
echo "Error: gource is not installed. Run: sudo apt install gource"
exit 1
fi

if ! command -v ffmpeg >/dev/null 2>&1; then
echo "Error: ffmpeg is not installed. Run: sudo apt install ffmpeg"
exit 1
fi

echo "Repo: $REPO_PATH"
echo "Output: $OUTPUT"
echo "Rendering... this can take a few minutes for larger repos."

cd "$REPO_PATH"

gource
--title "$(basename "$REPO_PATH")"
-1280x720
--seconds-per-day 0.3
--auto-skip-seconds 0.5
--hide mouse,progress
--key
--highlight-users
--file-idle-time 0
--max-file-lag 0.1
--background-colour 000000
--output-ppm-stream -
| ffmpeg -y
-r 60
-f image2pipe
-vcodec ppm
-i -
-vcodec libx264
-preset medium
-pix_fmt yuv420p
-crf 20
"$OUTPUT"

echo "Done. Saved to: $OUTPUT"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment