Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Gstreamer RTSP stream latency
QtWS25 Last Chance

Gstreamer RTSP stream latency

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 5.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ALopes
    wrote on 24 Jan 2023, 10:15 last edited by
    #1

    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

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JoeCFD
      wrote on 25 Jan 2023, 14:33 last edited by
      #4

      play a gstreamer pipeline directly. You have your own latency setting.
      https://doc.qt.io/qt-5/qmediaplayer.html#setMedia

      A 1 Reply Last reply 30 Jan 2023, 07:47
      2
      • K Offline
        K Offline
        Kent-Dorfman
        wrote on 24 Jan 2023, 10:31 last edited by Kent-Dorfman
        #2

        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.

        A 1 Reply Last reply 25 Jan 2023, 11:09
        0
        • K Kent-Dorfman
          24 Jan 2023, 10:31

          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.

          A Offline
          A Offline
          ALopes
          wrote on 25 Jan 2023, 11:09 last edited by ALopes
          #3

          @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.

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JoeCFD
            wrote on 25 Jan 2023, 14:33 last edited by
            #4

            play a gstreamer pipeline directly. You have your own latency setting.
            https://doc.qt.io/qt-5/qmediaplayer.html#setMedia

            A 1 Reply Last reply 30 Jan 2023, 07:47
            2
            • J JoeCFD
              25 Jan 2023, 14:33

              play a gstreamer pipeline directly. You have your own latency setting.
              https://doc.qt.io/qt-5/qmediaplayer.html#setMedia

              A Offline
              A Offline
              ALopes
              wrote on 30 Jan 2023, 07:47 last edited by
              #5

              @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 Reply Last reply
              0

              1/5

              24 Jan 2023, 10:15

              • Login

              • Login or register to search.
              1 out of 5
              • First post
                1/5
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved