Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use a Video Producer to write on frames being displayed?

How to use a Video Producer to write on frames being displayed?

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 Posters 3.2k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    davecotter
    wrote on last edited by davecotter
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by SGaist
      #2

      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.
      

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • D Offline
        D Offline
        davecotter
        wrote on last edited by davecotter
        #3

        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.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          davecotter
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            davecotter
            wrote on last edited by
            #5

            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
            
            
            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              What exactly are you trying to do ? Your code is not really clear on the aspect.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • D Offline
                D Offline
                davecotter
                wrote on last edited by
                #7

                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)

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Then shouldn't you rather make use of video filters ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    davecotter
                    wrote on last edited by
                    #9

                    my app is C++ Widgets, not QML

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      davecotter
                      wrote on last edited by
                      #10

                      i think it just needs a wee bit more documentation, or better yet, a sample project? anyone?

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        davecotter
                        wrote on last edited by
                        #11

                        please does ANYONE know how to use this? is there ANY more doc or sample code on this ?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          After some thoughts, I'd check the VLC-Qt and VLC. I think it will likely be more powerful for the features you are looking for.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved