Important: Please read the Qt Code of Conduct -

How to use appsrc with streams properly

  • Hi,

    I have a MPEG-TS stream that comes over either UART, ort eth, and I want to play it with QMediaPlayer. I am reading at a separate thread and have created a QLocalSever and writing stream to clients.

    At constructor:

        m_mediaPlayer = new QMediaPlayer(this, QMediaPlayer::StreamPlayback);

    After connecting a client with QLocalSocket:

        QString pipeline = QString("gst-pipeline: appsrc is-live=true format=time ! "
                                   "tsdemux ! h264parse ! avdec_h264 ! videoconvert ! "
                                   "xvimagesink name=\"qtvideosink\"");
        m_mediaPlayer->setMedia(QUrl(pipeline), &m_localSocket);

    Status changes to BufferedMedia but no videoAvailableChanged() or bufferStatusChanged() signals are triggered:

    void MainWindow::mediaStatusChanged(QMediaPlayer::MediaStatus) "" 2
    void MainWindow::mediaStateChanged(QMediaPlayer::State) "" 1
    void MainWindow::mediaStatusChanged(QMediaPlayer::MediaStatus) "" 6 

    Is this approach the right way ?
    How can we use appsrc to play stream ?

    Edit: Qt version: 5.12.6, OS: Ubuntu

  • Forget to mention, I tried sending over UDP and grabing with a udpsrc pipeline like at the docs and it worked. But I dont want to carry over UDP and lost packages.

  • At windows, both udpsrc and appsrc didnt work. Gives this error:

    DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x800c000d ()

    The docs says:

    The Qt Multimedia APIs build upon the multimedia framework of the underlying platform. This can mean that support for various codecs or containers can vary between machines, depending on what the end user has installed.

    Is this mean we cannot use full featured gst-pipeline on all platforms ?

  • Lifetime Qt Champion


    GStreamer is the Linux backend. If you want to use it on other platforms, you'll have to compile the backend yourself.

  • @SGaist Thanks for the reply.

    I checked the docs, and it shows GStreamer backend is only for Unix:

    And only two windows specific backends listed here:

    If I build GStreamer and its plugins and GStreamer plugin, can I use it as shown QMediaPlayer::setMedia() example ?

  • Lifetime Qt Champion

    I haven't tried it yet on Windows, but AFAIK, it should work like that.

Log in to reply