Animated GIFI recorded the printing of muddtt's Solidoodle Ext. Z-Stop Screw and turned it into this GIF:
That GIF started as a 15 minute 1080p video that was over 2 gigabytes. Run it through this script that uses mplayer and ImageMagick and the result is the 7 second GIF file that is a little over 1 megabyte:
#!/usr/bin/perl -w
my $newpath='/huge/vids/scripts';
$newpath=`$newpath/echo-path`;
chomp($newpath);
$ENV{'PATH'}=$newpath;
my $vidfile = $ARGV[0];
my $vidwidth;
my $vidheight;
my $vidsecs;
my $idh;
open($idh, '-|', "mplayer -frames 0 -identify -vo null -ao null $vidfile 2>/dev/null");
while (<$idh>) {
if (/^ID_VIDEO_WIDTH=(\d+)$/) {
$vidwidth = $1;
} elsif (/^ID_VIDEO_HEIGHT=(\d+)$/) {
$vidheight = $1;
} elsif (/^ID_LENGTH=(\d+\.\d+)$/) {
$vidsecs=$1;
}
}
my $incsec = $vidsecs/71.0;
my $ss = $incsec;
my $i;
my $montage="montage";
my $gengif="convert -delay 10";
for ($i = 0; $i < 70; ++$i) {
my $fs = sprintf("%04.6f",$ss);
system("mplayer -nosound -ss $fs -frames 1 -vo png:z=1:prefix=mptmp $vidfile");
$fs = sprintf("%02d",$i);
system("convert mptmp00000001.png -rotate 2.5 -crop '731x548+679+274!' -resize 160x120 -normalize sstmp$fs.png");
unlink("mptmp00000001.png");
$gengif .= " sstmp$fs.png";
$ss += $incsec;
}
$gengif .= " animated.gif";
system($gengif);
That script is clearly not general purpose, but tweaked just for the video I took. I knew there were about 70 layers in the print, so I figured taking one frame about every 70 seconds would be about right. The rotate and crop arguments were produced by examining a sample frame with gimp, using the measure tool to figure out how much the bed was tilted in the video (I don't have a tripod, so I just had the camera clumsily propped up on a small table with some books and such wedging it into place), then I examined the result of the rotation in gimp again to figure out where to crop. Finally I rescaled to make a smaller file and used the normalize argument to see if it would improve the image color a bit. Go back to my main Solidoodle page. |