LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   how to stream a webcam with python (https://www.linuxquestions.org/questions/programming-9/how-to-stream-a-webcam-with-python-905968/)

gary_in_springhill 10-01-2011 04:42 PM

how to stream a webcam with python
 
I'm trying to stream/view a webcam via a python app. I've tried pygame and it works great with an actual pci capture card but v4l complains with even a well known can like logitech. Xawtv works fine with the logitech though.

In pygame I get

SystemError: ioctl(VIDIOC_S_FMT) failure: no supported formats

for the logitech cam.

Other than using an external app like xawtv is there any known ways to view via a python app? I don't want to record just view in 2 sizes 320x240 and 640x480 hopefully with command line switches.
here is the small view app using pygame

Code:

#!/usr/bin/env python

import pygame, sys
import pygame.camera
from pygame.locals import *
pygame.init()
pygame.camera.init()
screen = pygame.display.set_mode((320,240))
cam = pygame.camera.Camera("/dev/video4",(320,240))

cam.start()
while 1:
        image = cam.get_image()
        screen.blit(image,(0,0))
        pygame.display.set_caption(str("TUX PLOT CAM"))
        pygame.display.update()
        for event in pygame.event.get():
          if event.type == pygame.QUIT:
            sys.exit()


corp769 10-01-2011 06:47 PM

Hello,

I came across this for you - http://webcamspy.sourceforge.net/
Would that help? Let me know man.

Cheers,

Josh

gary_in_springhill 10-01-2011 08:17 PM

mplayer
 
I just decided to use mplayer as a subproc. it works fine and quality is good.

thanks


All times are GMT -5. The time now is 01:45 AM.