X-Received: by 10.224.17.140 with SMTP id s12mr15134190qaa.3.1360152764432; Wed, 06 Feb 2013 04:12:44 -0800 (PST) X-Received: by 10.49.94.143 with SMTP id dc15mr2375762qeb.32.1360152764381; Wed, 06 Feb 2013 04:12:44 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!p13no15246433qai.0!news-out.google.com!k2ni8440qap.0!nntp.google.com!p13no15246429qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Wed, 6 Feb 2013 04:12:44 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=94.72.192.167; posting-account=TejjHAoAAADkS2KGneh-APCsC96PgtnN NNTP-Posting-Host: 94.72.192.167 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Recording live video stream from IP camera issue From: Sam Berry Injection-Date: Wed, 06 Feb 2013 12:12:44 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.python:38268 Hey, I have no vast knowledge of python, but i came across this code to capture video from my IP camera import urllib2 import time import logging print "Recording video..." response = urllib2.urlopen("IP Address") filename = time.strftime("%Y%m%d%H%M%S",time.localtime())+".avi" f = open(filename, 'wb') video_file_size_start = 0 video_file_size_end = 1048576 * 20 # end in 20 mb block_size = 1024 while True: try: buffer = response.read(block_size) if not buffer: break video_file_size_start += len(buffer) if video_file_size_start > video_file_size_end: break f.write(buffer) except Exception, e: logging.exception(e) f.close() This code works, however when i try to playback the .avi file in VLC player (file wont open in any other media player) it just flashes an image instead of a video file, even though the .avi file is around 20mb. Is there some extra lines of code i need to include or change? Perhaps a timing option instead of a file size? Any help or insight would be much appreciated!! Thanks, Sam