Motion - Support Question 2005x 01x 28x 222114

How to easily automatically access the last n motion detected jpeg files?


Thanks for motion! What I am after is something like this: just as lastsnap.jpg is the last picture taken, it would be very useful to have something like lastmotion.jpg, lastmotion-1.jpg, lastmotion-n.jpg where n is <5. If there is a simple way of doing this, it would be much appreciated. Thanks!


Motion version: 3.1.17
ffmpeg version: not used
Libraries: curl, xmlrpc
Server OS: Linux Fedora Core 3, kernel 2.6.10-1.737_FC3

-- TWikiGuest - 28 Jan 2005


This is a perl script that I use.

It assumes using the default filename for the saved jpegs.

jpeg_filename %v-%Y%m%d%H%M%S-%q

It keeps the last 200 jpegs. You can change it to 5 if you want.

It also creates a text file called largelist.php which is simply a list of the files in the right order.

It is then easy to load this from a PHP page and make a nice presentation. See also KennethsWebcamPackage.

To run the script set the onsave option. Example:

onsave /usr/local/bin/

And now the perl script.

chomp (@files = `ls -t *-*.jpg`);
$count = scalar @files;
$displaynumber = 200;
$displaynumber = $count if $displaynumber > $count;
print "Matched $count files\n";

my @sortedfiles = sort { ($b =~ /-(.*)-(.*)\./)[0] .  ($2=="snapshot"? "00" : $2) <=> ($a =~ /-(.*)-(.*)\./)[0] . ($2=="snapshot"? "00" : $2) } @files;
unlink @sortedfiles[$displaynumber..($count-1)] if $displaynumber < $count;
open(LISTFILE, ">largelist.php");
for ($i=0;$i < $displaynumber;$i++)
    print LISTFILE "@sortedfiles[$i]\n";

-- KennethLavrsen - 28 Jan 2005

SupportForm edit

TopicTitle How to easily automatically access the last n motion detected jpeg files?
SupportStatus AnsweredQuestions
SubmittedBy TWikiGuest
Topic revision: r2 - 28 Jan 2005, KennethLavrsen
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.