Pavol Rusnak #cypherpunk #hacker #openhw #privacy #bitcoin #newmediaart

Timelapse video with webcam and mplayer

Some time ago I created a timelapse video using webcam and mplayer:

Today I was asked how I did it and because I did not remember exactly the command line options I decided to write this post to save you some time reading manpages.

First step is to grab series of JPG images from mplayer using webcam:

while true; do
  # grab one frame from webcam and save it as 00000001.jpg
  mplayer tv:// -vo jpeg -frames 1
  # rename 00000001.jpg to something like 1344271221.jpg
  mv 00000001.jpg $(date +%s).jpg
  # sleep 1 second
  sleep 1

Once we are done (break the script with Ctrl+C) we can play the sequence using:

mplayer mf://*.jpg

If we are satisfied with the result we can convert these images to video using mencoder (usually located in the same package as mplayer):

mencoder mf://*.jpg -ovc lavc -o out.avi

For more options about creating video or video formats please read mencoder manpage, but lavc output should be OK for most of you . :-)