Unsolved How to use a Video Producer to write on frames being displayed?
-
Looking at this documentation, under the "Working with Low Level Video Frames" section, it says:
The following snippet shows a class that has a writable videoSurface property and receives frames through a public slot onNewVideoContentReceived(). These frames are then presented on the surface set in setVideoSurface().
However, it gives no clue as to how to hook it up, and provides no example code. Is there a sample that does something like this? eg: draw some text or show a graphic badge, OVER a movie as it's playing?
-
Hi,
It's in the paragraph above:
Several of the built-in Qt classes offer this functionality as well, so if you decode video in your application, you can present it to classes that offer a QVideoRendererControl class, and in QML you can set a custom object for the source of a VideoOutput with either a writable videoSurface property (that the instance will set it's internal video surface to) or a readable mediaObject property with a QMediaObject derived class that implements the QVideoRendererControl interface.
-
i saw that, but what i need is some sample code. it's not immediately obvious how to hook it up. or rather: it's no obvious after several hours of reading, researching, googling, and trying a dozen things.
-
also, i'm not using QML, so that doesn't apply to me. if it DOES apply, then the structure of that sentence does NOT make that clear.
I miss "Inside Macintosh", the quality of that documentation has never been surpassed.
-
if it helps, here's some code that i have, i just can't figure out how to shoehorn the video producer thing in there:
QGridLayout *layout = new QGridLayout; QTimer *timer = new QTimer(this); //AddSurface<Widget>(this, layout, timer, "Native", columnI++); //AddSurface<GLWidget>(this, layout, timer, "OpenGL", columnI++); #if 1 { #if OPT_MACOS CFileRef movieFile(CFileRef::kFolder_DESKTOP); #else CFileRef movieFile("Z:\\Users\\davec\\Desktop"); #endif ERR(movieFile.GetChild("Movies/test.mp4", &existsB)); if (!err && existsB) { QMediaPlayer *mediaPlayer = new QMediaPlayer(NULL, QMediaPlayer::VideoSurface); QGraphicsVideoItem *videoItem = new QGraphicsVideoItem(); QGraphicsView *graphicsView = new QGraphicsView(new QGraphicsScene(this)); QSizeF vidSize(340, 200); videoItem->setSize(vidSize); #if 0 mediaPlayer->setVideoOutput(videoItem); #else MyVideoSurface *vidSurfaceP = new MyVideoSurface(); MyVideoProducer *vidProducerP = new MyVideoProducer(); vidProducerP->setVideoSurface(vidSurfaceP); QVideoRendererControl *rendererControl = mediaPlayer->requestControl<QVideoRendererControl *>(); rendererControl->setSurface(vidProducerP); // mediaPlayer->setVideoOutput(vidSurfaceP); #endif graphicsView->scene()->addItem(videoItem); SuperString filePath(movieFile.path(true)); QUrl fileUrl(QUrl::fromLocalFile(filePath)); mediaPlayer->setMedia(fileUrl); mediaPlayer->play(); layout->addWidget(graphicsView, 0, columnI++); } } #endif
-
What exactly are you trying to do ? Your code is not really clear on the aspect.
-
just insert the video producer into the chain and have the movie still play. the goal is to be able to write to video frames while the movie is playing (eg: put a graphic badge on it, or draw some text over the movie, like subtitles)
-
Then shouldn't you rather make use of video filters ?
-
my app is C++ Widgets, not QML
-
i think it just needs a wee bit more documentation, or better yet, a sample project? anyone?
-
please does ANYONE know how to use this? is there ANY more doc or sample code on this ?
-