1

I am trying to get a GStreamer test video to play in a Qt QVideoWidget using the Qt example code from here but the video never plays. The Qt widget is just a blank window like in this screenshot.

enter image description here

The code I am using is listed below. I am using Qt 5.13.0.

#include <QtWidgets/QApplication>
#include <QVideoWidget>
#include <QtMultimedia/QMediaPlaylist>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    auto player = new QMediaPlayer;
    auto videoWidget = new QVideoWidget;
    player->setMedia(QUrl("gst-pipeline: videotestsrc ! xvimagesink name=\"qtvideosink\""));
    videoWidget->show();
    player->setVideoOutput(videoWidget);
    player->play();

    return a.exec();
}

I have been able to successfully play a video in the Qt QVideoWidget from a video file using the same setup but with the following setMedia() call so I know the QVideoWidget will play video:

    player->setMedia(QUrl::fromLocalFile("C:/Users/<MyUser>/Videos/testVideo.wmv"));

I am also able to play the test video using GStreamer from the command line using the following:

gst-launch-1.0.exe videotestsrc ! autovideosink

It plays the test video shown below. This is what I would like to play in the Qt QVideoWidget.

enter image description here

user3716193
  • 476
  • 5
  • 21
  • The gstreamer plugin is only available for Linux, windows uses directshow I think. – eyllanesc Mar 22 '22 at 14:59
  • Ohh, that's unfortunate. I must have missed that in the Qt documentation when I was looking at it. Are you aware of any other way to get the video to display in a Qt widget? I have been able to use GStreamer independent from Qt on a Windows c++ application and get the video to display but it opens in its own window and I need it to display in a Qt widget. – user3716193 Mar 22 '22 at 15:11
  • Maybe you have to compile the gstreamer plugin for windows to work, I don't know – eyllanesc Mar 22 '22 at 15:12

0 Answers0