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:
Disected, it means:
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)
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.
Thanks, looking into inotifywait.