Skip to content

Instantly share code, notes, and snippets.

@mguijarr
Created May 11, 2016 11:43
Show Gist options
  • Save mguijarr/0a8e53b85b50bfab18d801dd4c8c861f to your computer and use it in GitHub Desktop.
Save mguijarr/0a8e53b85b50bfab18d801dd4c8c861f to your computer and use it in GitHub Desktop.
import urllib
proxy = { }
stream = urllib.urlopen("http://d302.esrf.fr/mjpg/1/video.mjpg", proxies=proxy)
data = ""
i = 0
while True:
data += stream.read(16*1024)
a = data.find('\xff\xd8')
b = data.find('\xff\xd9')
if a != -1 and b != -1:
jpg = data[a:b+2]
data = data[b+2:]
# new image
i+=1
f=open("/tmp/bla%d.jpg"%i, "w"); f.write(jpg); f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment