Gstreamer RTSP stream latency
-
wrote on 24 Jan 2023, 10:15 last edited by
Hi,
I'm currently working on a project where I need to show a camera stream on a
QGraphicsView
, my code looks something like this:QMediaPlayer m_mediaPlayer = new QMediaPlayer(nullptr, QMediaPlayer::StreamPlayback); QGraphicsView* m_graphicsView = new QGraphicsView(this); QGraphicsVideoItem *videoItem = new QGraphicsVideoItem; videoItem->setPos(0, 0); videoItem->setSize(QSize(800, 520)); QGraphicsScene *scene = new QGraphicsScene(this); scene->addItem(videoItem); m_graphicsView->setScene(scene); m_mediaPlayer->setVideoOutput(videoItem); m_mediaPlayer->setMedia(QUrl("rtsp://10.90.8.175:554/stream0"));
Right now I can open the stream and display the video, but the only problem is that I have some 2s delay, that adds up over time making the stream even worse.
I saw something interesting that when I tried opening the stream directly using the:
gst-launch-1.0 playbin uri=rtsp://10.90.8.175:554/stream0
I also get the same delay as in my application. But if I specify the latency as in the command bellow the stream plays perfectly.
gst-launch-1.0 playbin uri=rtsp://10.90.8.175:554/stream0 uridecodebin0::source::latency=100
Because the app have some real time requirements on the stream playback, I'm trying to get something under 300ms of latency.
So my question is if you have any idea on how can I add the additional latency parameter to the
QMediaPlayer
object.
If you have any idea on some other ways to do this I would appreciate the hep.More about my setup:
I'm using qt 5.15.2 on Fedora link. I Also have played around with adding":network-caching=200"
to the source URL but nothing changed. I'm also okay with solutions using Qt 6.Thanks,
Andersen -
wrote on 25 Jan 2023, 14:33 last edited by
play a gstreamer pipeline directly. You have your own latency setting.
https://doc.qt.io/qt-5/qmediaplayer.html#setMedia -
wrote on 24 Jan 2023, 10:31 last edited by Kent-Dorfman
interesting problem. I'm not aware of acces to the requested level of control of the gstreamer backend from within Qt. Other consideration: caching and real-time are mutually exclusive.
A foggy alcohol damaged portion of my brain seems to recall that you can set up "profiles" that are read by gstreamer and since Qt uses it as the backend, those profiles could provide hooks. Or I could be mistaken.
-
interesting problem. I'm not aware of acces to the requested level of control of the gstreamer backend from within Qt. Other consideration: caching and real-time are mutually exclusive.
A foggy alcohol damaged portion of my brain seems to recall that you can set up "profiles" that are read by gstreamer and since Qt uses it as the backend, those profiles could provide hooks. Or I could be mistaken.
wrote on 25 Jan 2023, 11:09 last edited by ALopes@Kent-Dorfman said in Gstreamer RTSP stream latency:
A foggy alcohol damaged portion of my brain seems to recall that you can set up "profiles" that are read by gstreamer and since Qt uses it as the backend, those profiles could provide hooks. Or I could be mistaken.
Hey Kent,
Thanks for the quick answer, I looked around for GStreamer profiles or ways to set the default settings for GStreamer used in the system, but I was unable to find anything so far that allows me to change the default GStreamer buffering. -
wrote on 25 Jan 2023, 14:33 last edited by
play a gstreamer pipeline directly. You have your own latency setting.
https://doc.qt.io/qt-5/qmediaplayer.html#setMedia -
play a gstreamer pipeline directly. You have your own latency setting.
https://doc.qt.io/qt-5/qmediaplayer.html#setMediawrote on 30 Jan 2023, 07:47 last edited by@JoeCFD Thanks you, this one solved my problem. In case anyone have a similar problem this is how my code looks now:
m_mediaPlayer->setMedia(QUrl("gst-pipeline:rtspsrc location=rtsp://10.90.8.175:554/stream0 latency=10 ! rtph265depay ! h265parse ! avdec_h265 ! videoconvert ! autovideosink"));
1/5