PDA

View Full Version : Phonon in QGraphicsScene - no video, Linux/X11.



kamil
28th October 2010, 16:39
Hello

I would like to place widgets with transparent backgrounds on top of Phonon VideoPlayer in my application.
I think the perfect solution for me is to use QGraphicsScene and embed a VideoPlayer widget into it. Unfortunately doing so doesn't show any video. The window is whole white, I can only hear the sound of the playback.

Here is my code:

#include <QtGui>
#include <Phonon/VideoPlayer>

int main(int argc, char **argv)
{
QApplication app(argc, argv);
QGraphicsScene *scene = new QGraphicsScene;

Phonon::VideoPlayer player;
player.play(QString("//home/kamil/snowball.mp4"));
player.setMinimumSize(300, 200);

scene->addWidget(&player);

QGraphicsView view(scene);
player.show();
view.show();
view.setWindowTitle(QLatin1String("Graphicsview embedded phonon"));
view.setGeometry(50, 50, 600, 400);

return app.exec();
}
Adding "view.setViewport(new QGLWidget);" to the code doesn't make any difference. When I comment line 13 //scene->addWidget(&player); VideoPlayer shows as separate window and everything works just fine, there is audio and video. Media Player example, from qtdemo, works fine as well. Judging by that, I think the problem may be some system settings/xorg settings/graphics driver or even video card.

My video card is Mobilny Radeon HD 5165, but seen by the system as "Mobility Radeon HD 4650". I've tried diffrent software configurations: Gnome with free drivers, Kubuntu 2.6.32-25 with free/ati drivers, Qt 4.6.2/4.7.0 - none works. On ati drivers (OpenGL v. 3.2.9756) I've even managed to run all OpenGL examples from qtdemo. I also tried to run my code on Intel GM965/GL960, Linux-2.6.36, xorg-server-1.9.1, xf86-video-intel-2.13.0, mesa-7.8.2, qt-4.6.3, no result. The only configuration that worked fine was Kubuntu on VirtualBox on NVidia, but the performance was poor, and colors of video playback were some kind of broken.

Are you aware of any specyfic requirements, that system must meet in order to render video via QGraphicsScene properly? Can you tell what might be the problem in my case? I can provide any additional info about my configuration if this can help tracing the problem.

And finally, can you enumerate some Linux configurations (excluding virtual machines), that you tested, or that are known to work fine with phonon embedded into QGraphicsScene?

Best regards,
Kamil

umerlaton
20th September 2011, 16:05
Hi, dont know if its a really late answer but here it goes.....

QGraphicsView *view = new QGraphicsView(this);

Phonon::MediaSource source(QFileDialog::getOpenFileName(this,"VIDEOS","C:\\","Videos (*.wmv *.mpg *.mp4)"));
Phonon::MediaObject *mediaObject = new Phonon::MediaObject(this);

mediaObject->setCurrentSource(source);

Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory, this);
Phonon::VideoWidget *videoWidget = new Phonon::VideoWidget(view);
Phonon::createPath(mediaObject, audioOutput);
Phonon::createPath(mediaObject, videoWidget);

QGraphicsScene *scene = new QGraphicsScene;
view->setScene(scene);
QGraphicsProxyWidget *pVdoWidget = scene->addWidget(videoWidget);
mediaObject->play();


hope it works for you, and if you already know a better way for using phonon inside qgraphicsview, plzzz post it.
cya

kamil
21st September 2011, 02:00
After a week of trying it turned out, that this works only on nvidia cards (no matter if on vm, or not). I still have completely no idea why. This only confirmed my belief, that it was some kind of "system settings/xorg settings/graphics driver or even video card" issue. I think it might have been fixed by now with some system package upgrade, but I can't confirm this.

Broken colors on nvidia was a result of a bug in phonon-gstreamer backend. The patch is somewhere around.

I didn't run your code, but I don't think it would work at the time I was struggling with the problem. :(

What I finally did was to use QGLWidget as a parent of QGraphicsView and draw everything with openGl instructions. I hacked phonon-gstreamer backend and Qt's source to get frame data instead of letting phonon draw the frame itself. This resulted in noticable cpu usage drop when playing heavy videos.

This works, but to be honest with you, still sucks. I need a hardware acceleration. I need it bad. And get rid of phonon by the way. :mad: