So I'm using the command line utility "webcam" to save frames from a camera to a folder in /var/www for remote viewing, but I also want to save frames. The files range from 2k to 20k. One frame per second is saved. I have the following script running the camera.
Now this is all great but MAN do these files stack up. A day directory ranges from 500 to 1000MB. So, I want to modify my script to save every nth frame taken. Preferably 5th. For security reasons. Maybe one every 20 seconds. Who knows. How would I go about doing that? I was thinking a for loop somehow but I just can't seem to make it work.Code:#!/bin/sh webcam /etc/cam/webcamrc & # saves 1 frame per second while : do convert /var/www/[redacted]/outdoor.jpg -resize 50% /var/www/[redacted]/outdoor_sm.jpg #smaller, 320x240 copy if [ ! -d "/home/[redacted]/security/$(date +%Y)/$(date +%m)/$(date +%d)/$(date +%H)" ] then mkdir -p /home/[redacted]/security/$(date +%Y)/$(date +%m)/$(date +%d)/$(date +%H) #copy it to a folder year/month/day/hour if that exists, otherwise make it fi cp /var/www/[redacted]/outdoor_sm.jpg /home/[redacted]/security/$(date +%Y)/$(date +%m)/$(date +%d)/$(date +%H)/outdoor-$(date +%Y.%m.%d.%H.%M.%S).jpg #and make sure it's named year.month.day.hour.minute.second.jpg sleep 0.75 #this takes 250ms on this system so sleep for the rest of the second done
Bookmarks