Skip to Content

Webcam stop motion

whirlpool's picture

I wrote a 10 line python script to grab the photos and by a simple mencoder command, I create the video.

The python script:

  1. !/usr/bin/python
import urllib, time, sys i = 0 while 1: j = str(i).zfill(6) filename = "webshot%s.jpg"%j urllib.urlretrieve(url, filename) time.sleep(duration) i = i + 1

This work by: ./webcamer.py URL seconds

The only issue with this script is that it doesn't check if the downloaded image is an undamaged jpeg. As you will find that sometimes the downloading of the image will happen at the same time it is being uploaded. However, this is not very frequent. I resolve them manually.

The mencoder command:

mencoder "mf://*.jpg" -mf fps=25 -o output.avi -ovc lavc

Ah, BTW I think those stop motion sequences could really be a good source of video for VJ's. They can be looped, ping ponged etc..

One more tip, try starting the sequence by night. This way when they loop you will not notice a change in the cloud pattern.

Comments

whirlpool's picture

To answer some FAQs

When deciding the duration, test it yourself in the browser first. keep on refreshing and see how many seconds it takes to refresh. Ofcourse, if the webpage explicitly says how frequent the image get updated. Use this data.

Even though you can choose the duration according to your needs. But be aware that you will encode the video at 25 frames per second. Which means a 12 hour period will pass by in one second, if you decided to make the duration = 1800. This will not be smooth at all. However, if you take 1 shot every minute you will cover a 25 minutes period in one second. Which is very nice. Taking more frequent images, depend on what you need. Experiment and see.

The prague video above took 52M of jpg images space. The sequence covers aprox 20 hours period. One shot every minute. But the resulting video is just 5MB (RIFF (little-endian) data, AVI, 352 x 288, 25.00 fps, video: DivX 4) around 32 seconds. I think the resulting video can be even smaller, with the same quality. But I have no idea on how to do that.

Alaa's picture

easy peasy

mencoder -ovc xvid -oac mp3lame fooo.some_media_format

will generate an xvid/mp3 file called test.avi

cheers,

Alaa


"u know i once dream that the office of mobinil is from el 7`os :S and the one that answer u and tell u rasidak a girl called ghada"

You need to give it -xvidenop

You need to give it -xvidenopts bitrate=xxx or pass=x or it won't work right.

peace


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Dr. Radut | blog