You are not logged in.

#1 2013-06-08 11:57:07

nLinked
Member
Registered: 2013-04-06
Posts: 38

Need script: latest JPEGs to video, then delete old JPEGs

I have an IP cam which uploads JPEG pictures to an FTP folder on my Arch Linux box whenever it detects movement in the room it is looking in. It uploads a JPEG every second until all motion activity stops.

It names the JPEG files in the following way:
image.png

Disected, it means:
name-of-camera(inside)_1_YEAR-MONTH-DATE-TIME-SECONDS_imagenumber.jpg

I want a script that can make a 1 frame-per-second video from them (easy with ffmpeg I know), BUT, it must be clever enough to only make the video from the images that are within 2 seconds of each other, then delete those jpegs that it used. I say "2 seconds of each other" in-case of network latency where it misses one frame.

Any future images that are within 2 seconds of being taken, should become its own video.
So it should basically be able to make videos from each 'event' of motion the camera saw.

I know programs like zoneminder and motion can do this, but I want to design a script instead. Any ideas much appreciated.

Last edited by nLinked (2013-06-08 12:00:57)

Offline

#2 2013-06-08 12:29:55

Trilby
Forum Moderator
From: Massachusetts, USA
Registered: 2011-11-29
Posts: 14,000
Website

Re: Need script: latest JPEGs to video, then delete old JPEGs

This sounds like a job for inotifywait ([community]/inotify-tools).

You can have nested while loops, with the inner loop reading filesystem events from that folder.  The inner loop can be set to break when it has been two seconds since the last file creation.  After the inner loop breaks, make a video with ffmpeg, and rm all the jpegs.  Then the outer loop will go back to the start to do it all again if/when more images appear.


InterrobangSlider
• How's my coding? See this page.
• How's my moderating? Feel free to email any concerns, complaints, or objections.

Offline

#3 2013-06-08 17:56:08

nLinked
Member
Registered: 2013-04-06
Posts: 38

Re: Need script: latest JPEGs to video, then delete old JPEGs

Thanks, looking into inotifywait.

Offline

Board footer

Powered by FluxBB