You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Thursday, June 7th 2012, 10:40am

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

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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

Source code

1
Phonon::MediaSource medSrc( QString("/tmp/video.mp4" ));
line, the video is played as expected
if I use

Source code

1
 Phonon::MediaSource medSrc( QString("/dev/video" ));
line, 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.