Stories
Slash Boxes
Comments

SoylentNews is people

The Fine print: The following are owned by whoever posted them. We are not responsible for them in any way.

Journal by fliptop

As I've stated several times, cheap IP cameras are a little flaky. So even if you calculate the appropriate number of pictures to take in a 24-hour period, midnight will inevitably arrive and the script will still have a handful or two of pictures left to take.

So first we need to kill off the previous day's job. Here's the way to do that from cron:

00 00 * * * /bin/ps -o pid,args -U fliptop | /bin/grep grab_pic_tv-ip551wi.pl | /bin/grep -v grep | /usr/bin/xargs /bin/kill -15

Substitute the username your scripts run under for the -U switch and the name of your perl script in the 1st grep. Basically, this command takes all process that run under a particular user, greps out just the one process your script runs as, throws out any instances of the grep statement itself that may make their way into the results, then kills it w/ signal 15.

Next, at one minute after midnight, we start the next instance of the script for the new day:

01 00 * * * /bin/nice -n 19 /usr/bin/perl /home/fliptop/tv-ip551wi/grab_pic_tv-ip551wi.pl

Again, substitute the appropriate script location and name. I usually run these things nicely so they don't interfere too badly w/ other processes that run from time to time.

All that's left is to create the movie from the previous day's images:

03 02 * * * /bin/nice -n 19 /usr/bin/perl /home/fliptop/tv-ip551wi/ffmpeg.pl

As before, substitute the proper location and script name. You can run this at any time after midnight.

As you can imagine, watching surveillance video can be pretty boring since most of the time there's nothing noteworthy happening. However, once in a while you can see some damn interesting weather. One day last May I was reviewing some footage and thought to myself, "that would probably look pretty cool if it was edited a little w/ some Vivaldi."

Coming next, cleaning up your images.

Display Options Threshold/Breakthrough Reply to Article Mark All as Read Mark All as Unread
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
  • (Score: 2) by evilviper on Thursday April 10 2014, @12:06PM

    by evilviper (1760) on Thursday April 10 2014, @12:06PM (#29391) Homepage Journal

    That multi-pipe kill command seems like an awfully long way to go... The following should do the same job:

    * pkill -u fliptop -f grab_pic_tv-ip551wi.pl

    --
    Hydrogen cyanide is a delicious and necessary part of the human diet.
    • (Score: 2) by fliptop on Friday April 11 2014, @12:12AM

      by fliptop (1666) on Friday April 11 2014, @12:12AM (#29778) Journal

      Thanks for the tip, I'll try it! Linux is a lot like perl in that TMTOWTDI.

      --
      To be oneself, and unafraid whether right or wrong, is more admirable than the easy cowardice of surrender to conformity