How to make a timelapse shared memory server

The basic idea is this. You’ve got an old computer lying around. You’ve got a webcam or something else that can take pictures. So you can make yourself an information appliance. A simple one function shared device.

Can a timelapse server for a shared space serve a purpose like a logfile for a shared software development project?

Supplies:
1. Old pc/mac that is sitting a closet somewhere.
2. Capture card + external security cam OR usb webcam
3. optional web connection

Our current system is an old Dell Dimension running Fedora 11 Linux. Should work fine with most any linux distro.
Set up the machine:
1. install streamer(xawtv), ffmpeg, imagemagick, scrot(optional)
2. install scripts

The script for making timelapse movies is here:http://gist.github.com/475719
File includes many old comments but it’s a rather simple script.
Basic functionality:

initialize to a daily directory.
while [ 1 ]
do
if (new day)
then {make movie with ffmpeg, reinitialize to new daily directory}
fi
write timestamped jpg to daily directory
wait 20 seconds
done

The script for playing back the movies(videoloop.sh):

#! /bin/bash
while [ 1 ]
do
#mplayer -loop 0 -fs -shuffle /home/timelapse/Videos/copies/cam*.mp4
# vlc works too
mplayer -fs -shuffle /home/timelapse/Videos/copies/cam*.mp4
sleep 2 # this line is to make it easier to break out of.
# esc to leave playing. ctl-c to break out of script which will restart after 2 seconds.
done

don’t forget to make the scripts executable.

chmod 755 *.sh

If you’d like the movies to upload to a youtube channel automatically every night, you can do that as well. Instructions here.

A sample movie from the system:

Another earlier overview that shows some more detail about the actual connections:

another slight modified version that is at mit csail machine shop.

About these ads

Tags: , , , , ,

13 Responses to “How to make a timelapse shared memory server”

  1. Hackaday links: July 25, 2010 - Hack a Day Says:

    [...] source can be a great help to small businesses. Here’s a way to use a Linux machine to make time-lapse movies from surveillance camera feeds. We especially enjoy the use of a desktop wallpaper that has the terminal commands necessary [...]

  2. Hackaday links: July 25, 2010 | Video Game News, reviews, and information. Says:

    [...] source can be a great help to small businesses. Here’s a way to use a Linux machine to make time-lapse movies from surveillance camera feeds. We especially enjoy the use of a desktop wallpaper that has the terminal commands necessary [...]

  3. Greg Says:

    Uhm, is there a reason not to just use ZoneMinder for this?

    • t he ans weri saque stion? Says:

      we like writing script files! ;)
      zoneminder and motion look like good tools but we haven’t tried them. if anyone has a similar tutorial for one of those, please send along and we will add the link to the post.

  4. Todd Grigsby Says:

    The capture.sh you posted at github has several errors in it. Any chance you’ll post the corrected script?

    • t he ans weri saque stion? Says:

      can you post the errors you are getting? pretty sure the github version is one we are using. Certain shells respond differently so depending on mac/linux and various distributions, there are sometime small changes required.

  5. DarkSkyNet » How to make a timelapse shared memory server Says:

    [...] LINK HERE [...]

  6. Zach Says:

    I’d replace your backticks with “${foo}” to avoid splitting on whitespace. I see you have it in a couple of spots, but it isn’t consistent.

  7. t he ans weri saque stion? Says:

    exact capture.sh file on machine:

    #! /bin/sh

    # boranj!
    #
    # ***************************************
    # ******OMPD – One Minute Per Day – Voluntary Anthropology
    # ******public timelapse wall
    # need to install ffmpeg and imagemagick for this to work
    # maybe wacaw too if you want webcam.
    # mac tested but should be almost exactly same for linux.
    # **************
    # **************

    # whatever you want to be your directory of files
    cd ~/Pictures/OMPD
    # make a subdirectory with today’s date, then go to it.
    mkdir `date +%Y-%m-%d`
    cd `date +%Y-%m-%d`
    scrot lastscreen.jpg
    streamer -c /dev/video0 -o camLAST.jpeg

    DDDATE=`date +%Y%m%d`
    DATETIME=`date +%Y%m%d%H%M%S`

    counter=10000
    # at 15 seconds per shot, 4/min, 240/hr, 10 hours = 2400 shots
    # while [ $counter -ne 3400 ] # run a fixed number of shots.
    #while [ `date +%H` -lt 23 ] # if it’s less that 11pm
    while [ 1 ] # run all the time
    do
    DATETIME=`date +%Y%m%d%H%M%S`

    NOWDATE=`date +%Y%m%d`
    if [ $NOWDATE -gt $DDDATE ]
    then
    echo “day change”
    counter=10000
    # rename files sequentially for FFMPEG to work properly
    for f in screen*.jpg; do
    let “counter+=1″
    mv $f screen${counter:1}.jpg
    done
    counter=10000
    for f in cam*.jpg; do
    let “counter+=1″
    mv $f cam${counter:1}.jpg
    done

    # convert *.jpg ~/Movies/AUTOUPLOAD/OMPD-$DDDATE-$DATETIME.mp4
    # this is a one liner you can run if you need to manually do a day that got missed.
    # for f in *.jpg; do let “counter+=1″; mv $f screen${counter:1}.jpg ; done
    #done

    ffmpeg -r 20 -b 5000 -i screen%04d.jpg ~/Videos/screen$DDDATE.mp4

    ffmpeg -r 15 -sameq -i cam%04d.jpg ~/Videos/camTL-$DDDATE.mp4
    #ffmpeg -r 15 -b 5000 -i webcam%04d.jpg ~/Movies/AUTOUPLOAD/`
    # -b 5000 to limit movie size.
    cd ~/Pictures/OMPD
    mkdir `date +%Y-%m-%d`
    cd `date +%Y-%m-%d`
    counter=10000
    DDDATE=`date +%Y%m%d`
    scrot lastscreen.jpg
    streamer -c /dev/video0 -o camLAST.jpeg
    fi

    #let “counter+=1″
    echo $DATETIME
    #echo $counter # if you want to see the progression on the terminal window
    # capture a JPG screenshot

    HOURNOW=`date +%H`
    if [ $HOURNOW -gt 25 ]
    then
    #screencapture -m -x -t jpg screen${counter:1}.jpg
    #screencapture -m -x -t jpg screen$DATETIME.jpg
    scrot newscreen.jpg
    composite -blend 50 newscreen.jpg lastscreen.jpg middlescreen.jpg
    cp middlescreen.jpg lastscreen.jpg
    echo “captured screen”
    convert middlescreen.jpg -resize 60% screen$DATETIME.jpg
    # add additional imagemagick filters that intentionally art-ify the images?
    echo “made screen smaller”

    fi

    HOURNOW=`date +%H`
    if [ $HOURNOW -gt 8 ]
    then
    #scrot screen$DATETIME.jpg
    streamer -c /dev/video0 -o cam$DATETIME.jpeg
    #streamer -c /dev/video0 -o cam$DATETIME.jpeg
    #wacaw –jpeg -n 4 webcam${counter:1}.jpg
    echo “captured cameras”
    #composite -blend 20 camNEW.jpeg camLAST.jpeg camMiddle.jpg
    #mv camMiddle.jpg cam$DATETIME.jpg
    #rm camLAST.jpg
    convert cam$DATETIME.jpeg -resize 200% cam$DATETIME.jpg
    #cp camMiddle.jpg camLAST.jpg
    fi
    rm *.jpeg

    #wacaw –jpeg -n 4 webcam${counter:1}.jpg
    # resize images using imagemagick here?

    # convert webcam${counter:1}.jpg.jpeg -resize 95% webcam${counter:1}.jpg
    # mv webcam$DATETIME.jpg.jpeg webcam$DATETIME.jpg

    #convert screen${counter:1}.jpg -resize 50% screen${counter:1}.jpg

    # capture an image from the webcam using wacaw package. get from sourceforge
    #
    # download zip file. unzip. run these two things at command line
    # sudo cp wacaw /usr/local/bin; sudo chmod +x /usr/local/bin/wacaw
    echo yofool
    # number of seconds between shots
    sleep 20
    # make a beep here? display a shot onscreen?
    done
    # one shot/15sec, played at 10 fps = 150x speedup. 150min(2.5hr) = 1 min vid. 10hrs = 4min
    # about mac cron jobs on laptops and sleep times
    # http://www.thexlab.com/faqs/maintscri

  8. Mike Says:

    Hi, you can try SebecTec software to make a time-lapse.

  9. All Asia Timelapse Twvee « The Broadcaster Project Says:

    [...] The Broadcaster Project so you can really say, "i know where you're coming from" « How to make a timelapse shared memory server [...]

  10. PHANTASMA: DAN PALUSKA | DigBoston Says:

    [...] on a computer in the back corner of the music venue. Instructions to make your own are on his blog, and Paluska says he’d love if someone else took interest, tweaked the program in their own ways [...]

  11. Public Media Systems Workshop, Tuesdays 7-9pm in November, Cambrij « The Broadcaster Project Says:

    [...] you can learn to make if you want: A videobooth, a public timelapse server, command line video remixing, computer timelapse self surveillance, youtube upload scripts, a [...]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: