Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. "Using qtvideosink element without video surface" QMediaPlayer, QGraphicsVideoItem and , QGraphicsScene
QtWS25 Last Chance

"Using qtvideosink element without video surface" QMediaPlayer, QGraphicsVideoItem and , QGraphicsScene

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
11 Posts 3 Posters 1.3k Views
  • 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.
  • T Offline
    T Offline
    tungdil
    wrote on last edited by
    #1

    Hey, I'm developing an embedded Qt app with Qt 5.15.2 for the KR260 platform running Linux and this app involves running some gstreamer pipelines and displaying the video output on the screen.
    So, for this purpose I'm using the function and the declerations below:

    //Declerations in my header file
        QMediaPlayer *player_1 = new QMediaPlayer;
        QGraphicsVideoItem *item_1 = new QGraphicsVideoItem;
        QGraphicsScene *scene_1 = new QGraphicsScene;
    
    //Function
    void MainWindow::play_first()
    {
        player_1->setVideoOutput(item_1);
        item_1->setSize(QSizeF(width, height));
        player_1->setMedia(QUrl("gst-pipeline: videotestsrc pattern=snow ! videoconvert ! videoscale ! video/x-raw, width=683, height=384 ! videorate ! video/x-raw, framerate=15/1 !qtvideosink"));
        player_1->setMuted(true);  
        player_1->play();
    }
    

    When I run this function during the startup of the app I get the following run-time error on the console "Using qtvideosink element without video surface". But after some navigation on the app (so basically recalling the function again) everything seems to work fine. I also have some other players running such as this one and I'm having the same issue for all of them. I'm not sure if I have understood the concept correctly. I'm also using player_1->stop() to stop that player.
    So what is the correct way of starting, running and stopping a player with a gstreamer pipeline

    SGaistS JoeCFDJ 2 Replies Last reply
    0
    • T tungdil

      Hey, I'm developing an embedded Qt app with Qt 5.15.2 for the KR260 platform running Linux and this app involves running some gstreamer pipelines and displaying the video output on the screen.
      So, for this purpose I'm using the function and the declerations below:

      //Declerations in my header file
          QMediaPlayer *player_1 = new QMediaPlayer;
          QGraphicsVideoItem *item_1 = new QGraphicsVideoItem;
          QGraphicsScene *scene_1 = new QGraphicsScene;
      
      //Function
      void MainWindow::play_first()
      {
          player_1->setVideoOutput(item_1);
          item_1->setSize(QSizeF(width, height));
          player_1->setMedia(QUrl("gst-pipeline: videotestsrc pattern=snow ! videoconvert ! videoscale ! video/x-raw, width=683, height=384 ! videorate ! video/x-raw, framerate=15/1 !qtvideosink"));
          player_1->setMuted(true);  
          player_1->play();
      }
      

      When I run this function during the startup of the app I get the following run-time error on the console "Using qtvideosink element without video surface". But after some navigation on the app (so basically recalling the function again) everything seems to work fine. I also have some other players running such as this one and I'm having the same issue for all of them. I'm not sure if I have understood the concept correctly. I'm also using player_1->stop() to stop that player.
      So what is the correct way of starting, running and stopping a player with a gstreamer pipeline

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      When exactly is ˋplay_first` called ?

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

      T 1 Reply Last reply
      0
      • T tungdil

        Hey, I'm developing an embedded Qt app with Qt 5.15.2 for the KR260 platform running Linux and this app involves running some gstreamer pipelines and displaying the video output on the screen.
        So, for this purpose I'm using the function and the declerations below:

        //Declerations in my header file
            QMediaPlayer *player_1 = new QMediaPlayer;
            QGraphicsVideoItem *item_1 = new QGraphicsVideoItem;
            QGraphicsScene *scene_1 = new QGraphicsScene;
        
        //Function
        void MainWindow::play_first()
        {
            player_1->setVideoOutput(item_1);
            item_1->setSize(QSizeF(width, height));
            player_1->setMedia(QUrl("gst-pipeline: videotestsrc pattern=snow ! videoconvert ! videoscale ! video/x-raw, width=683, height=384 ! videorate ! video/x-raw, framerate=15/1 !qtvideosink"));
            player_1->setMuted(true);  
            player_1->play();
        }
        

        When I run this function during the startup of the app I get the following run-time error on the console "Using qtvideosink element without video surface". But after some navigation on the app (so basically recalling the function again) everything seems to work fine. I also have some other players running such as this one and I'm having the same issue for all of them. I'm not sure if I have understood the concept correctly. I'm also using player_1->stop() to stop that player.
        So what is the correct way of starting, running and stopping a player with a gstreamer pipeline

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by JoeCFD
        #3

        @tungdil said in "Using qtvideosink element without video surface" QMediaPlayer, QGraphicsVideoItem and , QGraphicsScene:

        "Using qtvideosink element without video surface"

        Did you install the plugin of gstreamer for Qt5?
        gstreamer1.0-qt5

        T 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          When exactly is ˋplay_first` called ?

          T Offline
          T Offline
          tungdil
          wrote on last edited by
          #4

          @SGaist I have a number of players in my app but right now I'm trying to debug one of them to figure out the concept, so I cut down the code a little. For example I encounter this error twice (the message gets printed twice) when I launch the app with the following constructor function. Also as you can tell I'm using a QGraphicsView class for this purpose and it is named "graphicsView".

          MainWindow::MainWindow(QWidget *parent)
              : QMainWindow(parent)
              , ui(new Ui::MainWindow)
          {
              ui->setupUi(this);
          
              ui->graphicsView->setScene(scene_1);
              ui->graphicsView->scene()->addItem(item_1);
          
              ui->tabWidget->setCurrentIndex(0);
              play_first();
          }
          
          1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @tungdil said in "Using qtvideosink element without video surface" QMediaPlayer, QGraphicsVideoItem and , QGraphicsScene:

            "Using qtvideosink element without video surface"

            Did you install the plugin of gstreamer for Qt5?
            gstreamer1.0-qt5

            T Offline
            T Offline
            tungdil
            wrote on last edited by
            #5

            @JoeCFD yes I already installed it via apt but I didn't add it as a plugin to the Qt Creator, if that's the case I don't know how to do it. Add plugin tool expects me to give it a zip file but I couldn't find it.

            JoeCFDJ 1 Reply Last reply
            0
            • T tungdil

              @JoeCFD yes I already installed it via apt but I didn't add it as a plugin to the Qt Creator, if that's the case I don't know how to do it. Add plugin tool expects me to give it a zip file but I couldn't find it.

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #6

              @tungdil No need. Plugin is installed at the proper location. Wait you use widgets. Please try to install qt-gstreamer which has qtvideosink

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

                Rather than calling it from the constructor, use a 0 based QTimer to trigger the slot. That will ensure that it start as soon as the event loop itself is started which means that all the internal plumbing is up and running.

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

                T 1 Reply Last reply
                0
                • SGaistS SGaist

                  Rather than calling it from the constructor, use a 0 based QTimer to trigger the slot. That will ensure that it start as soon as the event loop itself is started which means that all the internal plumbing is up and running.

                  T Offline
                  T Offline
                  tungdil
                  wrote on last edited by
                  #8

                  @SGaist I defined and started a timer just like you said in the constructor to call the play_first function on timeout as:

                      QTimer *test = new QTimer; //Defined in the header file
                      connect(test, &QTimer::timeout, this, &MainWindow::play_first); //Defined at the beginning of the constructor function
                      test->start(0); //Defined at the end of the constructor function
                  

                  But it didn't work at all.
                  I figured the setMedia() function of the player throws that error even though state() of the function returns QMediaPlayer::PlayingState. It is such a shame that GStreamer doesn't check whether the pipeline is actually playing or not.
                  I believe the way I'm constructing a multimedia functionality is wrong, so I tried the example here with an arbitrary gstreamer pipeline and it didn't work as well.
                  What is the correct way of playing a GStreamer pipeline on startup and giving the output video to an Qt element.

                  1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    @tungdil No need. Plugin is installed at the proper location. Wait you use widgets. Please try to install qt-gstreamer which has qtvideosink

                    T Offline
                    T Offline
                    tungdil
                    wrote on last edited by
                    #9

                    @JoeCFD I tried to build the package I downloaded from here, but since I'm using Ubuntu 22.04LTS I couldn't build it because it requires libidn11:i386 package and it is supported by 22.04LTS according to an answer given to my question here.
                    Also, in general I'm not sure if I actually need to build that package in the first place because, like I described in the question after running the play_first() function a couple of times from different places it seems to work fine.

                    JoeCFDJ 1 Reply Last reply
                    0
                    • T tungdil

                      @JoeCFD I tried to build the package I downloaded from here, but since I'm using Ubuntu 22.04LTS I couldn't build it because it requires libidn11:i386 package and it is supported by 22.04LTS according to an answer given to my question here.
                      Also, in general I'm not sure if I actually need to build that package in the first place because, like I described in the question after running the play_first() function a couple of times from different places it seems to work fine.

                      JoeCFDJ Offline
                      JoeCFDJ Offline
                      JoeCFD
                      wrote on last edited by JoeCFD
                      #10

                      @tungdil do not build it. You have to make quite some changes in order to build it from the source. Simply install it
                      sudo apt-get install qtgstreamer-plugins-qt5

                      Be aware of this package is not developed and maintained anymore. If you are making a product with Qt, better to use gstreamer or FFmpeg directly.

                      T 1 Reply Last reply
                      0
                      • JoeCFDJ JoeCFD

                        @tungdil do not build it. You have to make quite some changes in order to build it from the source. Simply install it
                        sudo apt-get install qtgstreamer-plugins-qt5

                        Be aware of this package is not developed and maintained anymore. If you are making a product with Qt, better to use gstreamer or FFmpeg directly.

                        T Offline
                        T Offline
                        tungdil
                        wrote on last edited by
                        #11

                        @JoeCFD thanks for your help. Since I'm running the development of the application on the Xilinx KR260 platform, I'm looking for a way to install this plugin on it, because I couldn't see it under the petalinux rootfs configuration menu.

                        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