Results 1 to 4 of 4

Thread: Show /dev/video (linux) stream into a Phonon::VideoWidget

  1. #1
    Join Date
    Jun 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Show /dev/video (linux) stream into a Phonon::VideoWidget

    Hi,
    On a linux ubuntu with Qt 4.8.1, I have a device driver that creates a /dev/video0 node.
    I would like to show the video into a videowidget with phonon. Is it possible ? any tip on how to do this ?

    I can open /dev/video0 with vlc and mplayer so the stream is surely created and available.

    Since Phonon's backend uses gstreamer, I investigated in this direction too.
    gstreamer-properties provides a mean to test video default input pipeline and this works, I can view the stream with this test.
    Pipeline field shows : v4l2src device="/dev/video0" though I don't know how to interpret that.

    On Qt side, my test code looks like
    Qt Code:
    1. int main(int argv, char **args)
    2. {
    3. QApplication app(argv, args);
    4.  
    5. Phonon::MediaObject* mediaObj = new Phonon::MediaObject();
    6. Phonon::VideoWidget* vidWid = new Phonon::VideoWidget();
    7. Phonon::createPath(mediaObj, vidWid);
    8.  
    9. Phonon::MediaSource medSrc( QString("/dev/video" ));
    10. //Phonon::MediaSource medSrc( QString("/tmp/video.mp4" ));
    11.  
    12. mediaObj->setCurrentSource( medSrc );
    13.  
    14. mediaObj->play();
    15.  
    16. std::cout<<"last err : "<<mediaObj->errorString().toStdString ()<<std::endl;
    17.  
    18. vidWid->show();
    19.  
    20. return app.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 
    if I use
    Qt Code:
    1. Phonon::MediaSource medSrc( QString("/tmp/video.mp4" ));
    To copy to clipboard, switch view to plain text mode 
    the video is played as expected
    if I use
    Qt Code:
    1. Phonon::MediaSource medSrc( QString("/dev/video" ));
    To copy to clipboard, switch view to plain text mode 
    the widget keeps desperately black
    errorString is always empty.

    Since Totem is also built onto gstream, I tried to open the stream with it but failed to get anything too.

    Any help would be greatly appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    70
    Thanked 59 Times in 57 Posts

    Default Re: Show /dev/video (linux) stream into a Phonon::VideoWidget

    Hi,

    As I can see, your device is "/dev/video0" and you are opening "/dev/video". Maybe this is the error?
    Òscar Llarch i Galán

  3. #3
    Join Date
    Jun 2012
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Show /dev/video (linux) stream into a Phonon::VideoWidget

    thank you for having a look at my problem.
    alas this is not the problem, I first tried to open /dev/video0 and then /dev/video as i grew desperate :-/

    but as you point it, I noticed that mplayer and vlc need not to be told that the stream is in /dev/video0, they find it themselves. Maybe using some v4l2 function to get info ?

  4. #4
    Join Date
    Jul 2012
    Posts
    4
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Show /dev/video (linux) stream into a Phonon::VideoWidget

    I figured this out. In order to have it display the stream that you are getting in, you need to give it the correct MRL, which is v4l2://///video/dev. However, I am trying to get this widget to display in QML and I have not been able to get it to do so. I have made it a registered QML element, but I cannot get it to display. Do you have any idea how to do that?

Similar Threads

  1. Phonon VideoWidget does not show video on Vista SP2
    By maxchan in forum Qt Programming
    Replies: 3
    Last Post: 16th December 2011, 20:49
  2. Phonon VideoWidget
    By prophet0 in forum Qt Programming
    Replies: 1
    Last Post: 7th November 2011, 12:43
  3. Phonon in QGraphicsScene - no video, Linux/X11.
    By kamil in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2011, 03:00
  4. Play video file with Phonon and GStreamer show black screen
    By SimbadSubZero in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2010, 12:47
  5. Live stream for Phonon video widget
    By Leolander in forum Qt Programming
    Replies: 0
    Last Post: 1st March 2010, 07:05

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.