Last Updated: June 11, 2021
·
3.841K
· datn

Take a photo of yourself every time you commit (Linux)

Inspired by Victor Martinez' nearly identical post for OSX: http://coderwall.com/p/xlatfq?i=9&p=1&q=

Use fswebcam https://github.com/fsphil/fswebcam
to capture a picture from the command line, and use the following as a post-commit script:

#!/usr/bin/env perl
use strict;
use warnings;
unless ( -d $ENV{"HOME"}."/.gitpix" ) {
    mkdir $ENV{"HOME"}."/.gitpix" or die "$!\n";
}
my $file="~/.gitpix/pic-".time.".jpg";
print "Saving image from webcam to $file.\n";
system "fswebcam $file" or die "$!\n";

Then use avconv, perhaps with ImageMagick morph transitions, to make the timelapse. Here's a little recipe for the shell, adapted from http://www.itforeveryone.co.uk/image-to-video.html:

#!/bin/bash
mkdir tl
# change TR (transition) to # of frames to fade between images. 
# you probably want lower numbers when you have more images
TR=10
FPS=24
convert .gitpix/*.jpg -delay $TR -morph $TR tl/%06d.transition.jpg
avconv -i tl/%06d.transition.jpg -r $FPS yourmovie.avi