Python-v4l: neat!
Thinking about CherryTV and ways to turn it into a real application, I thought the worse piece of it was the reliance on v4lctl, and how really you just don't know if it works or not, and how you can't finetune, and whatever, and run into Python-v4l.
It has remained apparently untouched by two years, but I managed to build it with one edit and to make it work by switching a line to an alternate version (they are both there), and it's nice.
Here's the example TV viewing application using it:
#!/usr/bin/env python # Sample TV viewing application for pyv4l >= 0.3 - by Michael Dove #<pythondeveloper@optushome.com.au> # Note: this does the imaging in grab mode. Performance is limited. # I average 35 fps @ 320x240. Disabling the writes to the tk window yeilds 90+ fps. import v4l import Image import ImageChops WIDTH = 320 HEIGHT = 240 vid = v4l.video('/dev/video') cap = vid.getCapabilities() print "Device Name: %s" % cap[0] print "Type: %d" % cap[1] print "Channels: %d" % cap[2] print "Audios: %d" % cap[3] print "Maximum Width: %d" % cap[4] print "Maximum Height: %d" % cap[5] print "Minimum Width: %d" % cap[6] print "Minimum Height: %d" % cap[7] vid.setupImage(WIDTH, HEIGHT, v4l.VIDEO_PALETTE_YUYV) print vid.getChannel(0) # TV vid.setChannel(0) # set to TV vid.setFrequency(216250) import Tkinter tk=Tkinter.Tk() import ImageTk photo = ImageTk.PhotoImage("RGB",(WIDTH,HEIGHT)) label= Tkinter.Label(tk,text="mini TV",image=photo,width=WIDTH,height=HEIGHT) label.pack() vid.preQueueFrames() nextFrame = 0; vid.setVolume(5) vid.mute() try: while 1: output = vid.getImage(nextFrame) im = Image.fromstring("RGB", (WIDTH, HEIGHT), output) # update Tk label photo.paste(im) tk.update() nextFrame = vid.queueFrame() except Tkinter.TclError: print "something" pass vid.mute()
If you have seen the equivalent C app... well... nice job here!
It's interesting you are trying to process the image internally - hence the FPS limit.
How about processing the channel change only, and just piping the image to a dedicated app, like Kaffeine?
I have a ivtv-based card, which outputs plain MP3 on /dev/video0. I coded a simple SuperKaramba applet for changing the channel (using ivtv-specific command-line app) and starting the Kaffaine with fifo://ved/video0. (Look for kataivtv on kde-look. I'll finish it some time after June 8th) That sure beats trying to process the video yourself.
I am streaming using vlc, and using python to switch channels via a web page (that's what python-v4l gives me).
This code is the example that comes with python-v4l, I just posted it because I was impressed by the simplicity.
Hi,
where did you found this v4l module
I can't seem to find it anywhere :(
nevermind, I found it :)
but what did you do to build it?
this is really interesting viewpoint on the subject i might add
Well, the write-up is truly the freshest on this laudable topic.