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. Set gstreamer rtsp latency=0
Forum Updated to NodeBB v4.3 + New Features

Set gstreamer rtsp latency=0

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 4.3k Views 2 Watching
  • 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.
  • D Offline
    D Offline
    dahan
    wrote on last edited by
    #1

    I want to play H.264 videos(rtsp protocol) with QMediaPlayer(Qt5.6.2 and Gstreamer1.8.1). It works but there is some latency about 2s.

    When I play the rtsp video with gst-launch, I use the command that like```
    //gst-launch-1.0 -v rtspsrc latency=0 location="rtsp://xx:554"

    
    So. How could I add such parameter to QMediaPlayer? Maybe should I add something to the component QtMultiMedia?
    1 Reply Last reply
    0
    • SGaistS SGaist

      That has nothing to do with Qt or GStreamer. When asking a question, you should always give as much details as you can about what you tried, what you excepted, what you actually get, etc.

      For example here: did you check if the methods you call have return values ? If so, did you check what they mean ?

      D Offline
      D Offline
      dahan
      wrote on last edited by
      #8

      @SGaist Thanks. When I use gst-launch-1.0 to play the video, I add the parameter "latency=0". and it plays almost real-time. So I want add such parameter to QMediaPlayer. I search the code of QtMultiMedia, and find that the file qgstreamerplayersession.cpp is about player. There is some code about "rtsp". I think the following code is important:

          } else if (qstrcmp(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source)), "GstRTSPSrc") == 0) { // line 1578
              //rtspsrc acts like a live source and will therefore only generate data in the PLAYING state.
              self->m_sourceType = RTSPSrc;
              self->m_isLiveSource = true;
              g_object_set(G_OBJECT(source), "buffer-mode", 1, NULL); // line 1583
              g_object_set(G_OBJECT(source), "latency", 0, NULL); // I add this line.Sorry to make a mistake above that I wrote wrong line number. It is not line 1586
              g_object_set(G_OBJECT(source), "threads", 4, NULL); // I add this line. I want to make QMediaPlayer work multi-thread.
      

      I am sure that the code will execute because when I add "g_object_set(G_OBJECT(source), "threads", 4, NULL); " , there will be warning in the console that rtspsrc does not have property "threads".

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #2

        Hi and welcome to devnet,

        AFAIK, you need to modify the QtMultimedia GStreamer backend for that to happen.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        D 1 Reply Last reply
        0
        • Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #3

          internet/IP/RTSP/UDP multimedia is not designed for zero latency. You are going to be dissappointed. There is ALWAYS inherent latency when streaming video over IP networks. In tightly controlled point-to-point configuration you might get it down to 100-150ms average latency but that's about as good as it gets.

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi and welcome to devnet,

            AFAIK, you need to modify the QtMultimedia GStreamer backend for that to happen.

            D Offline
            D Offline
            dahan
            wrote on last edited by
            #4

            @SGaist Thanks. I add "g_object_set(G_OBJECT(source), "latency", 0, NULL);" on line 1586 to the file qgstreamerplayersession.cpp, but it does not work.

            SGaistS 1 Reply Last reply
            0
            • D dahan

              @SGaist Thanks. I add "g_object_set(G_OBJECT(source), "latency", 0, NULL);" on line 1586 to the file qgstreamerplayersession.cpp, but it does not work.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #5

              @dahan said in Set gstreamer rtsp latency=0:

              but it does not work.

              You know that with that high level of details it's mostly Crystal Ball debugging ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              D 1 Reply Last reply
              1
              • SGaistS SGaist

                @dahan said in Set gstreamer rtsp latency=0:

                but it does not work.

                You know that with that high level of details it's mostly Crystal Ball debugging ?

                D Offline
                D Offline
                dahan
                wrote on last edited by
                #6

                @SGaist emm, I am so new with QtMultiMedia and Gstreamer that I just try.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #7

                  That has nothing to do with Qt or GStreamer. When asking a question, you should always give as much details as you can about what you tried, what you excepted, what you actually get, etc.

                  For example here: did you check if the methods you call have return values ? If so, did you check what they mean ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  D 1 Reply Last reply
                  1
                  • SGaistS SGaist

                    That has nothing to do with Qt or GStreamer. When asking a question, you should always give as much details as you can about what you tried, what you excepted, what you actually get, etc.

                    For example here: did you check if the methods you call have return values ? If so, did you check what they mean ?

                    D Offline
                    D Offline
                    dahan
                    wrote on last edited by
                    #8

                    @SGaist Thanks. When I use gst-launch-1.0 to play the video, I add the parameter "latency=0". and it plays almost real-time. So I want add such parameter to QMediaPlayer. I search the code of QtMultiMedia, and find that the file qgstreamerplayersession.cpp is about player. There is some code about "rtsp". I think the following code is important:

                        } else if (qstrcmp(G_OBJECT_CLASS_NAME(G_OBJECT_GET_CLASS(source)), "GstRTSPSrc") == 0) { // line 1578
                            //rtspsrc acts like a live source and will therefore only generate data in the PLAYING state.
                            self->m_sourceType = RTSPSrc;
                            self->m_isLiveSource = true;
                            g_object_set(G_OBJECT(source), "buffer-mode", 1, NULL); // line 1583
                            g_object_set(G_OBJECT(source), "latency", 0, NULL); // I add this line.Sorry to make a mistake above that I wrote wrong line number. It is not line 1586
                            g_object_set(G_OBJECT(source), "threads", 4, NULL); // I add this line. I want to make QMediaPlayer work multi-thread.
                    

                    I am sure that the code will execute because when I add "g_object_set(G_OBJECT(source), "threads", 4, NULL); " , there will be warning in the console that rtspsrc does not have property "threads".

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #9

                      @dahan said in Set gstreamer rtsp latency=0:

                      g_object_get

                      I would check with a g_object_get call to see if the value was indeed set.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      D 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        @dahan said in Set gstreamer rtsp latency=0:

                        g_object_get

                        I would check with a g_object_get call to see if the value was indeed set.

                        D Offline
                        D Offline
                        dahan
                        wrote on last edited by
                        #10

                        @SGaist Thanks a lot. I do check with g_object_get, and the property latency is setted successfully.
                        I find that QtMultiMedia use gstreamer plugin playbin. I play the video with command gst-launch-1.0 playbin latency=10 uri=rtsp://xx:554 . On my machine it does not play as good as gst-launch-1.0 rtspsrc latency=10 location=rtsp://xx:554. So I think it's problem of the gstreamer plugin "playbin". I will try replace playbin with rtspsrc in QtMultiMedia.

                        1 Reply Last reply
                        0

                        • Login

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