Feature request: time lapse of motion detection events
  • I've asked for this feature before, but I just thought of a different (and possibly easier) way to do it, so I'll re-phrase and suggest in a different way:

    Problem: I have some cameras with a lot of activity. I have time-lapse set on them, but 99% of the frames in the time-lapse show no activity, especially at night. Super-tedious. I have motion detection, but that ends up with a slew of files that are "real-time" and I have to spend HUGE amounts of time seeing what's happening.

    What I want: A quickly-viewed summary of all of the frames during the day in which motion occurred.

    Solution: Take all of the motion detection files for a camera between times S and E. Perform a concatenation of all of those files (connect them together, end-to-beginning, in time-ordered sequence.) Now, perform a time-lapse function on that large resulting video blob, extracting a frame every N seconds of the real-time playback. Play that resultant sub-set of frames at P fps. S, E, N, and P are user-definable and might even be decimals.

    This would allow the user to view all of the activity for a large span of time in a very short period. It may or may not even require actually creating a new file - maybe it's entirely done on the fly at the time of request, or is a temp file that can be saved off if the user finds it interesting, or just gets deleted if older than a certain time value. An added bonus would be the ability to tag each frame in that time-lapse with the meta-data for the "real-time" playback file, so the user could jump directly to the slower high-detail version with a right-click or some other method.

    JT
  • Hi JT,

    It's a good idea, and I can certainly see the use, but we simply don't get users requesting such a feature, and we have to prioritise our development resources.

    Have you tried viewing the motion-detection files via the web interface? Click the "show all previews" button. The preview images will contain the first frame in which motion was detected, so it should be very easy and quick to scan down the list (or grid) and see which files contain interesting motion.

    Does this work for you?
  • I think this is a case of people not knowing that something _could_ exist, therefore they do not ask for it. I described this feature to several security staff who spend all day in front of monitoring software, and their eyes opened wide and they said "That would be a FANTASTIC IDEA!"

    Sadly, the show all previews method provides too much friction to work well, and circumstantially increasing the number of interfaces for interaction (app-vs-web) is going backwards. I'll work on a script, perhaps.
  • OK, so I decided to whip this up myself. Not the prettiest shell script ever, but it does the trick.

    NOTE: I found that my versions of Quicktime nor SecuritySpy would open the resulting MPEG files but VLC opened them just fine. No idea what's going on there but it's too late to try to hunt that problem down right now. If anyone has an answer on how to make Quicktime-compatible MOV files from mencode, please post a followup here.

    #!/bin/bash
    # Description: make time lapse video from SecuritySpy videos
    # Usage: md-lapse.sh < source-directory > < frames >
    # Source Directory: the directory of motion detection events that you are wanting to speed up
    # Frames: the number of frames to pull per second (1 will speed it up the most, 10 will be slower)
    #
    # You will need "mencode" and "ffmpeg" for this to work.
    # You can use Brew or whatever package installer you like for ffmpeg, and mencode is here:
    # http://prdownloads.sourceforge.net/mplayerosx/ffmpegXbinaries20060307.zip
    #
    # Original idea swiped from: http://pr0gr4mm3r.com/linux/how-to-create-a-time-lapse-video-using-ffmpeg/
    #

    TEMP="/tmp/ffmpeg_temp"
    SOURCE=$1
    FPS=$2

    # If there were no command line options, use current directory and 1fps
    : ${SOURCE:="."}
    : ${FPS:="1"}

    echo "Starting motion detection time lapse on directory $SOURCE - this may take a while!"

    # Make sure we're correctly cleaned up before starting.
    cd $SOURCE
    rm -rf $TEMP
    mkdir $TEMP

    # Concatenate all files that have "MD" (aka: motion detection events) in the filename and make one big file...
    mencoder -really-quiet -oac copy -ovc copy -idx -o $TEMP/output.mov *MD*.mov > /dev/null 2>&1

    # Now take that file, and cut it up into PNG images, taking only < frames > of frames per second...
    ffmpeg -loglevel quiet -i $TEMP/output.mov -r $FPS -f image2 $TEMP/%05d.png

    # Now take all those .png files and squash them together in a 20 frame-per-second movie called "ML.mov"
    #
    # If you want, here are some additional commands that might be useful to add in this line:
    # -vf scale=640:480 - scales output movie to 640 by 480
    #
    mencoder -really-quiet -nosound -ovc lavc -lavcopts vcodec=mpeg4 -o ./ML.mov -fps 20 mf://$TEMP/*png > /dev/null 2>&1

    # clean up the junk files
    rm -rf $TEMP

    echo "Finished directory $SOURCE - file ML.mov is in that directory."

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!