"Using qtvideosink element without video surface" QMediaPlayer, QGraphicsVideoItem and , QGraphicsScene
-
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 -
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 pipelineHi,
When exactly is ˋplay_first` called ?
-
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 -
@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(); }
-
@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 -
@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.
-
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.
-
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.
@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. -
@tungdil No need. Plugin is installed at the proper location. Wait you use widgets. Please try to install qt-gstreamer which has qtvideosink
@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. -
@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.@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-qt5Be 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.
-
@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-qt5Be 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.