PDA

View Full Version : QGraphicsEffect on a Phonon::VideoPlayer



scary_jeff
19th January 2011, 20:37
Hi

I am trying to write my first Qt app. The point of the app is to try to demonstrate a video processing algorithm. I had a look around the documentation, and it seemed like I should apply a QGraphicsEffect to a Phonon::VideoPlayer, but I cannot get the graphicseffect to make any difference, with the video playing normally. To start with, my effect simply does nothing at all (empty function) - the idea being that the video will never be drawn. Maybe at this point I have already gone wrong in my approach to this, in which case please ignore the rest of the post :D.

I tried altering my program so that the 'VideoPlayer' object is actually a QLabel with pixmap loaded into it. In this case, everything works as expected - no image is drawn, but if I add the single line: drawSource(painter); to my QGraphicsEffect's overloaded draw() function, the image is drawn correctly. This proves to me that my QGraphicsEffect and general program structure are both set up properly.

Applying the effect to the parent window instead of the video widget makes no difference (except for the parent window being 'corrupt' as the whole window is never actually drawn; it seems to contain random garbage from some graphics memory somewhere). I also tried moving the setGraphicsEffect function to different points in the program (just after the videoPlayer is created, just after the media file is loaded), and this made no difference either.

Any ideas or suggestions would be greatly appreciated.

Here is the relevant section of the widget (derived from QWidget) containing the video. I haven't included my QGraphicsEffect, as it doesn't actually do anything at this point (bear in mind the app does appear to work if VIDEO is not defined):


#ifdef VIDEO
Phonon::VideoPlayer *videoPlayer = new Phonon::VideoPlayer(Phonon::VideoCategory, this);
#else
QPixmap *Pixmap = new QPixmap();
Pixmap->load("/home/jeff/Examples/logos/logo-edubuntu.png");
QLabel *videoPlayer = new QLabel();
videoPlayer->setPixmap(*Pixmap);
#endif //def VIDEO

grid->addWidget(videoPlayer, 1, 0, 3, 1);

cTestFilter *TestFilter = new cTestFilter(this, videoPlayer->size());

#ifdef VIDEO
// load video file
Phonon::MediaSource MediaFile("/home/jeff/Examples/Ubuntu_Free_Culture_Showcase/UbuntuIsHumanity.ogv");
videoPlayer->load(MediaFile);
videoPlayer->play(MediaFile);
#endif //def VIDEO


videoPlayer->setGraphicsEffect(TestFilter);
//this->setGraphicsEffect(TestFilter);

wysota
19th January 2011, 21:15
You can't apply any effects to Phonon. It's strictly for playing movies using whatever capabilities the backend offers. There is no way to modify particular frames of the movie. If you need that, use QtMultimedia framework.

scary_jeff
19th January 2011, 22:22
Hi Wysota

Thanks for the information. I'll try to find some examples of using this module.

How would I have know that effects could not be applied to Phonon objects? I'm a bit confused that I can call setGraphicsEffect on an item that does not support graphics effects!

Oh well, thanks.

wysota
20th January 2011, 01:12
The docs say:

Phonon does not allow manipulation of media streams directly, i.e., one cannot alter a media stream's bytes programmatically after they have been given to a media object.


The multimedia functionality is not implemented by Phonon itself, but by a back end - often also referred to as an engine. This includes connecting to, managing, and driving the underlying hardware or intermediate technology. For the programmer, this implies that the media nodes, e.g., media objects, processors, and sinks, are produced by the back end. Also, it is responsible for building the graph, i.e., connecting the nodes.


We also hope in the future to be able to support direct manipulation of media streams. This will give the programmer more freedom to manipulate streams than just through processors.