View Single Post
Posts: 125 | Thanked: 108 times | Joined on Feb 2010
#12
I have added an additional variable "jetztstr" which helps avoid name clashes in the destination directory.
I.e. when you call the script more than once, you can distinguish between the picture series by file name, which begins with timestamp of the first taken shot of each series.

Code:
#!/usr/bin/perl -w

# A simple intervalometer for the Nokia N900.
# Author: Ricardo Mendonca Ferreira - ric@mpcnet.com.br
# http://talk.maemo.org/showthread.php?t=38275

# This script requires gstreamer installed on your N900.
# See the link above for more info.
# Run this script on an X Terminal in your device with:
#   perl intervalometer.pl

# 2009.12.17  First version.
# 2009.12.24  Better gstreamer pipeline; more options, with better descriptions.
# ############ rm changes rudolf.mittelmann@artm-friends.at
# 2010-02-22 Try to use better file naming to avoid name clashes - new var jetztstr

use strict;
use POSIX qw(strftime);

#---- CONFIG SECTION ---- [BEGIN] ----

 my ($x,$y) = (1600, 1200);              # image resolution - try (2592, 1968)
 my $cam    = 0;                        # camera: 0 = back, 1 = front
 my $dir    = '/home/user/MyDocs/interval'; # folder where images will be saved
 my $max    = 10;  # total number of images to take
 my $delay  =  5;  # interval between pictures

#---- CONFIG SECTION ----  [END]  ----

die "$dir not found!\n" if !-d $dir;

my $jetztstr = strftime ("%Y-%m-%d_%H-%M-%S_", localtime());

my $gst = "/usr/bin/gst-launch v4l2camsrc device=/dev/video$cam num-buffers=1 ! ffmpegcolorspace ! video/x-raw-yuv,width=$x,height=$y ! jpegenc ! filesink location=";

my $num=0;

print "Intervalometer started - will take $max pictures at $x x $y\n";

while ($num < $max) {
	$num=sprintf'%05d',$num;
	`$gst$dir/$jetztstr$num.jpg`;
	printf "saved %d of %d", $num+1, $max;
	$num++;
	if ($num < $max) { print " - sleeping $delay sec."; sleep $delay; }
        print "\n";
}
it is only a small, trivial change, but somebody on Twitter requested to post it, so here it is.

Last edited by rm53; 2010-02-26 at 21:00.
 

The Following User Says Thank You to rm53 For This Useful Post: