Steve_BZ has asked for the wisdom of the Perl Monks concerning the following question:

Hi People,

I have been developing a wxPerl application for about a year now, one of my outstanding issues is how to get a live video feed to display. So far I have been using Wx::MediaCtrl and all my testing has been done on stored videos. However, I feel the time has come to bite the bullet and get the live feed to work. I am developing on Linux (Kubuntu) and Wx::MediaCtrl uses GStreamer as the back end. I had hoped that I could simply use:

$success_status = $i_frame->{Ctl_Videos_Media}->LoadURI ('/dev/video0');

but it doesn't work, it doesn't give me an error message, and it doen't even return a success status (but if I do a GetStatus on it I get '0').

My second thought was:

*However*, there is hope, if I run the following command at a command prompt: gst-launch-0.10 v4l2src ! tee name=videoout ! queue ! videorate ! video/x-raw-yuv,fps=15 ! queue ! theoraenc quality=60 ! queue ! muxout. oggmux name=muxout ! filesink location=lulz.ogg videoout. ! queue ! ffmpegcolorspace ! ximagesink, I get a stored file which I can seek through and a live feed being displayed through a window with about a half-second latency. If only that window was a MediaCtrl window it would be perfect. As gst-launch is a GStreamer application and Wx::MediaCtrl uses Wx::GStreamerMediaBackend, I assume that I can somehow splice these programs together, but here I get lost.

As usual, your wisdom and thoughts would be very welcome.

Regards

Steve

Replies are listed 'Best First'.
Re: Using Wx::MediaCtrl to display a live videofeed (eg a webcam)
by Corion (Patriarch) on Jul 20, 2010 at 12:38 UTC

    If you can push raw frames (in YUV or RGB format) to the Wx::MediaControl, then you can use ffmpeg to read from the webcam and convert and output the raw frames to STDOUT. You set up a filehandle to read from there and push the frames into the Wx frame. I have something not unlike this (except that my build of ffmpeg.exe does not want to read from the video camera and that I use OpenGL to render the output) in App::VideoMixer.

      Hi Corion,

      I thought I had posted a reply to this yesterday, but maybe it got lost in the confusion. My power-supply blew up spectacularly (loud bang and smoke) taking motherboard and CPU with it, luckily not HD. I need to rebuild my PC, but as I'm off for a week tomorrow, it'll be the end of next week before I can do it.

      Thanks for your input

      Regards

      Steve

Re: Using Wx::MediaCtrl to display a live videofeed (eg a webcam)
by Anonymous Monk on Jul 20, 2010 at 12:44 UTC
    Do you have a wxLogWindow? Some kind of error message should be reported... Can you run it with strace?

      Hi Anon,

      Thanks for this. I didn't have LogWindow installed, so I just did that and I get:

      21:56:14: Error: gst_error_callback Error Message:Invalid URI "/dev/video0". Debug:gstplaybasebin.c(1666): gen_source_element (): /GstPlayBin:play (error 0: Success) 21:56:14: Error: wxGStreamerMediaBackend::Load - Could not set initial + state to ready (error 0: Success)

      I guess it doesn't like the /dev/video0. Maybe it really expects a URL, but assuming it means a URI, then should I just put my computer name in front of it like this? steve-desktop/dev/video0 because that doesn't work either.

      Do you know what format is correct?

      Thanks and regards

      Steve.

      PS I tried the strace, but it gave me pages and pages of info. I'll have a go at filtering it down, and post it here.

        $ perl -MURI::file -le"die URI::file->new( shift )->canonical " /dev/v +ideo0 file:///dev/video0
Re: Using Wx::MediaCtrl to display a live videofeed (eg a webcam)
by Kirsle (Pilgrim) on Jul 21, 2010 at 17:08 UTC
    I've done something similar with Perl/Tk, using ffmpeg to get an mjpeg stream and split the jpeg images up and display them in a regular imagelabel widget.

    See node: 792758

Re: Using Wx::MediaCtrl to display a live videofeed (eg a webcam) - Solved
by Steve_BZ (Chaplain) on Aug 11, 2011 at 11:27 UTC

    Update

    Thanks everyone for your input. In fact just last night, I got a fix from the wxWidgets mailing list.

    The answer for anyone else who comes looking is:

    The Linux webcam should be addressed as v4l2:///dev/video0. Make sure that's a letter l (lower case L, not upper case i and not a numeral l) in the v4l2.

    Now I have beautiful streaming webcam!

    Regards

    Steve

      Wow, to wait a whole year ... I wonder if v4lc: was available then
        Sorry, v4l2 - I've updated my post.