title: python video capture loop
body: <p>I've written a simple script to continuously capture snapshots from my webcam. My only issue is the videocapture module doesn't always grab an image which in turn crashes the program. I think I could solve this by using an infinite loop but I'm not real certain how to go about it. Here's the script:</p>
  
  <pre><code>from VideoCapture import Device
  import datetime
  def capt():
    a = datetime.datetime.now().strftime("%Y%m%dT%H%M%S%ms")
  
    b = str(a)
    cam = Device(devnum=0)
    cam.setResolution(1280, 960)
  
    cam.saveSnapshot('%s.png' % (b))
  
  for i in range(1, 100000):
    capt()
  </code></pre>