PDA

View Full Version : Show /dev/video (linux) stream into a Phonon::VideoWidget



azen0r
7th June 2012, 10:53
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

int main(int argv, char **args)
{
QApplication app(argv, args);

Phonon::MediaObject* mediaObj = new Phonon::MediaObject();
Phonon::VideoWidget* vidWid = new Phonon::VideoWidget();
Phonon::createPath(mediaObj, vidWid);

Phonon::MediaSource medSrc( QString("/dev/video" ));
//Phonon::MediaSource medSrc( QString("/tmp/video.mp4" ));

mediaObj->setCurrentSource( medSrc );

mediaObj->play();

std::cout<<"last err : "<<mediaObj->errorString().toStdString ()<<std::endl;

vidWid->show();

return app.exec();
}
if I use
Phonon::MediaSource medSrc( QString("/tmp/video.mp4" )); the video is played as expected
if I use
Phonon::MediaSource medSrc( QString("/dev/video" )); 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.

^NyAw^
7th June 2012, 11:34
Hi,

As I can see, your device is "/dev/video0" and you are opening "/dev/video". Maybe this is the error?

azen0r
7th June 2012, 13:26
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 ?

bluestreak
1st August 2012, 17:18
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?