capture time-lapse movies

24th July 2019 at 4:26pm
code computer image processing instructions
Word Count: 167

We wrote the following bash script called timelapse to capture still frames from a webcam (by default, /dev/video0) and then stitch them together into a time-lapse movie. It takes a single argument on the command line, the name of the movie.

It captures 1000 frames, with roughly 5 seconds between them, where each frame is made up of 10 normal-speed frames averaged together. This means that it runs for about 6000 seconds = 100 minutes = 1 hour & 40 minutes and the resulting video is about 1000/25 = 40 seconds long. If you wan to change any of these you need to edit the script (or better make a copy).

To run it type timelapse my_movie_name

for ((i=0;i<1000;i++)); do
    mplayer --really-quiet -vo tga -frames 10 tv://
    python average.py $1
    sleep 5
  done
mencoder mf://$1*png -mf fps=25:type=png -ovc lavc -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o $1.mpg