Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to use appsrc with streams properly
huseyinkozan last edited by huseyinkozan
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.
m_mediaPlayer = new QMediaPlayer(this, QMediaPlayer::StreamPlayback); m_mediaPlayer->setVideoOutput(ui->videoWidget);
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); m_mediaPlayer->play();
Status changes to
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 ?
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:
I haven't tried it yet on Windows, but AFAIK, it should work like that.