Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38268

Recording live video stream from IP camera issue

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 <ffa5fb6e-2d2c-484c-bfae-1014f1d0ebcc@googlegroups.com> (permalink)
Subject Recording live video stream from IP camera issue
From Sam Berry <sambez_14@hotmail.co.uk>
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Recording live video stream from IP camera issue Sam Berry <sambez_14@hotmail.co.uk> - 2013-02-06 04:12 -0800
  Re: Recording live video stream from IP camera issue Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-02-06 23:26 +1100
    Re: Recording live video stream from IP camera issue Sam Berry <sambez_14@hotmail.co.uk> - 2013-02-06 04:36 -0800
  Fwd: Recording live video stream from IP camera issue Xavier Ho <contact@xavierho.com> - 2013-02-06 23:39 +1100
    Re: Recording live video stream from IP camera issue Sam Berry <sambez_14@hotmail.co.uk> - 2013-02-06 05:12 -0800
      Re: Recording live video stream from IP camera issue Xavier Ho <contact@xavierho.com> - 2013-02-07 01:35 +1100
        Re: Recording live video stream from IP camera issue Sam Berry <sambez_14@hotmail.co.uk> - 2013-02-17 06:15 -0800
          Re: Recording live video stream from IP camera issue Xavier Ho <contact@xavierho.com> - 2013-02-18 06:57 +1100
        Re: Recording live video stream from IP camera issue Sam Berry <sambez_14@hotmail.co.uk> - 2013-02-17 06:15 -0800
    Re: Recording live video stream from IP camera issue Sam Berry <sambez_14@hotmail.co.uk> - 2013-02-06 05:12 -0800
  Re: Recording live video stream from IP camera issue Sam Berry <sambez_14@hotmail.co.uk> - 2013-02-18 05:03 -0800

csiph-web