Time lapse geekery

Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum

Help Support Homebrew Talk - Beer, Wine, Mead, & Cider Brewing Discussion Forum:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.
Joined
Jul 24, 2006
Messages
14,260
Reaction score
786
Location
Southwest
I've seen a few folks post some time lapse footage here, and I wanted to give it a try. It turns out that it's quite easy under Ubuntu Linux using a webcam and video4linux. Software required includes mplayer and imagemagick.

The result: a boring movie where a candle burns and a beer is drained.
Captured every 5 seconds, replayed at 15 fps (75x speed).

[YOUTUBE]sMszDFgjQ9w[/YOUTUBE]

My shell scripts could probably be a little more elegant, but they work. Here are the details:

First, a script to start mplayer and capture images to be stored as png files in the current directory. Takes a single argument specifying the capture interval. To exit, close mplayer and hit Ctrl+c.
Code:
#!/bin/bash
# Time lapse script using mplayer

# Exit gracefully if no interval is specified
if [ "$1" = "" ]; then
  echo "Error: Please specify an image capture interval!"
  echo "USAGE: timelapse <interval>"
  echo "Where <interval> is an integer in seconds."
  exit
fi

# Make a FIFO file for use later
rm /tmp/timelapse.fifo
mkfifo /tmp/timelapse.fifo

mplayer -slave -quiet -input file=/tmp/timelapse.fifo -vf screenshot -tv driver=v4l:height=240:width=320 tv:// &

while true; do
  sleep "$1"
  echo "screenshot 0" > /tmp/timelapse.fifo
done

Next, a script to convert all the png images in the current directory to jpg format and encode them into a movie. Takes a single argument specifying the framerate.
Code:
#!/bin/bash
# Script to convert a series of png images to a movie

# Exit gracefully if no framerate is specified
if [ "$1" = "" ]; then
  echo "Error: Please specify an framerate!"
  echo "USAGE: capture2movie <framerate>"
  echo "Where <framerate> is an integer representing fps."
  exit
fi

echo "Converting png images to jpg format."
echo "This may take some time..."
for f in *png ; do
  convert -quality 100 $f `basename $f png`jpg
done

echo "Moving original captured images to folder ./backup."
mkdir backup
mv *.png backup

echo "Encoding movie..."
mencoder "mf://*.jpg" -mf fps="$1" -o test.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800
 
Thanks for the suggestion, but that software isn't gonna work in Linux, Bobby. It's Windows only, and v4l isn't supported under Wine (Windows emulator). I didn't find any time lapse software for Linux; that's why I wrote these scripts.

I wish I had a Canon digital camera. Many of them can be controlled remotely via USB, so you could potentially get very high res footage for these sorts of projects. I had to settle for the webcam for this one.

I can't wait to take some more interesting time lapse footage. I don't have a specific application in mind at the moment, it just seemed like a fun project on a lazy day.
 
I never thought I'd see the day when, while browsing a beer forum, I'd see a BASH script to turn a series of PNG images into a timeplapse movie. :)

I owe that man a sixer or something...

Any licenses on them there scripts?
 
Kevin Dean said:
Any licenses on them there scripts?
Nah, I snagged most of the good stuff from various sources on the web, anyway.

The mplayer command was one that someone was using to update a web page with webcam images. Instead of removing and replacing the image each time a capture occurs, I just let 'em pile up to be stitched together later.
 
El Duderino - Not into that whole brevity thing said:
Dumb question, but can you post the URL for the video?



If you hit "Quote" on Yuri's post you'll see "sMszDFgjQ9w" between YOUTUBE tags - tack those on the end of the YouTube link (watch?v=) and you've got the URL to the video. :)

Merry Christmas.
 
Last edited by a moderator:
...and finally...a Christmas time lapse video!

One frame every 200 seconds overnight, then one frame every 7 seconds during Christmas morning. For some reason YouTube cut off the last 3-4 seconds of the video (which is frustrating - I worked at synching the music so that it ended at an appropriate point).

[youtube]j1TcATXB-VQ[/youtube]

 
Last edited by a moderator:
I didn't find any time lapse software for Linux; that's why I wrote these scripts.

and isn't that the beauty? simple bash scripts can do quite a lot.
 
Kevin Dean said:
http://www.youtube.com/watch?v=sMszDFgjQ9w

If you hit "Quote" on Yuri's post you'll see "sMszDFgjQ9w" between YOUTUBE tags - tack those on the end of the YouTube link (watch?v=) and you've got the URL to the video. :)

Merry Christmas.

Thanks!
Unfortunately though, I can't do either of those tricks if I am surfing from my iPod touch, but if I have a youtube link (URL), it will play any youtube video. The embedded bids are sweet but sometimes not so sweet.
 
Back
Top