script de Python para grabar videos en vivo en línea
Estoy desarrollando un script para descargar videos en vivo en línea.
Mi Script:<code>print "Recording video..." response = urllib2.urlopen("streaming online video url") 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 * 7 # end in 7 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: logger.exception(e) f.close() </code>
El script anterior funciona bien para descargar 7Mb de video de contenidos de transmisión en vivo y almacenarlo en archivos * .avi.
Sin embargo, me gustaría descargar solo 10 segundos de video sin importar el tamaño del archivo y almacenarlo en un archivo avi.
Probé diferentes posibilidades pero sin éxito.
¿Podría alguien compartir su conocimiento aquí para solucionar mi problema?
Gracias por adelantado.