Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. RTSP stream delay which live stream a ip camera
QtWS25 Last Chance

RTSP stream delay which live stream a ip camera

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
8 Posts 2 Posters 1.6k 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.
  • G Offline
    G Offline
    greed_14
    wrote on last edited by
    #1

    Hello, I've been using Qt 6.3.1 for RTSP IP camera streaming. However, I've noticed a delay of approximately 3-4 seconds in the streaming process. Interestingly, when I perform the same streaming using Qt 5.15.2, there is no such delay. I am aware that Qtmultimeadia module has undergone modifications since Qt 6. Is there a way to eliminate this streaming delay? Additionally, there are instances when the delay isn't observed, I am getting a Warning: "A lot of buffers are being dropped." and video is getting struck

    Item {

    MediaPlayer {
        id: player
        source: "rtsp://admin:admin123@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0"
        videoOutput:  cameraout
        onPlaybackStateChanged: function(newState) {
            console.log("playback state changed",playbackState)
        }
        onErrorOccurred: function(error, errorString) {
            console.log("error occured ",error, errorString);
        }
        audioOutput: AudioOutput {
            id: audioOutput
        }
        onHasVideoChanged: {
            console.log("has video changed ",hasVideo);
    
        }
        onBufferProgressChanged: {
            console.log("buffer changed ",bufferProgress,player.bufferedTimeRange())
        }
        onVideoOutputChanged: {
            console.log("videoOutPut changed",error,errorString,hasVideo,source)
        }
        onMediaStatusChanged: {
            if(player.mediaStatus ==MediaPlayer.NoMedia){
                console.log("onMediaStatusChanged NoMedia",player.mediaStatus,MediaPlayer.NoMedia)
            }
            if(player.mediaStatus ==MediaPlayer.LoadingMedia){
                console.log("onMediaStatusChanged LoadingMedia",player.mediaStatus,MediaPlayer.LoadingMedia)
    
            }
            if(player.mediaStatus ==MediaPlayer.LoadedMedia){
                console.log("onMediaStatusChanged LoadedMedia",player.mediaStatus,MediaPlayer.LoadedMedia)
    
            }
            if(player.mediaStatus ==MediaPlayer.BufferingMedia){
                console.log("onMediaStatusChanged BufferingMedia",player.mediaStatus,MediaPlayer.BufferingMedia)
    
            }
            if(player.mediaStatus ==MediaPlayer.StalledMedia){
                console.log("onMediaStatusChanged StalledMedia",player.mediaStatus,MediaPlayer.StalledMedia)
    
            }
            if(player.mediaStatus ==MediaPlayer.BufferedMedia){
                console.log("onMediaStatusChanged BufferedMedia",player.mediaStatus,MediaPlayer.BufferedMedia)
    
            }
            if(player.mediaStatus ==MediaPlayer.EndOfMedia){
                console.log("onMediaStatusChanged EndOfMedia",player.mediaStatus,MediaPlayer.EndOfMedia)
    
            }
            if(player.mediaStatus ==MediaPlayer.InvalidMedia){
                console.log("onMediaStatusChanged InvalidMedia",player.mediaStatus,MediaPlayer.InvalidMedia)
    
            }
        }
        onPlaybackRateChanged: {
            console.log("onPlaybackRateChanged ",player.playbackRate)
        }
        onPositionChanged: {
            console.log("onPositionChanged ",player.position)
        }
        onSourceChanged: {
            console.log("onSourceChanged ",player.source)
        }
    
    }
    
    
    VideoOutput {
        id: cameraout
        anchors.fill:parent
    }
    
    Rectangle{
        id: playrect
        width: 100
        height:width
        color: "green"
        anchors.bottom: parent.bottom
        anchors.left: parent.left
        MouseArea{
            anchors.fill: parent
            onClicked: {
                player.source ="rtsp://admin:admin123@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0"
                player.play()
                console.log("play clicked")
            }
        }
    }
    Rectangle{
        id: pauserect
        width: 100
        height:width
        color: "red"
        anchors.bottom: parent.bottom
        anchors.right: parent.right
        MouseArea{
            anchors.fill: parent
            onClicked: {
                player.source = ""
                player.stop()
                console.log("stopped")
            }
        }
    }
    

    }

    JoeCFDJ 1 Reply Last reply
    0
    • G greed_14

      Hello, I've been using Qt 6.3.1 for RTSP IP camera streaming. However, I've noticed a delay of approximately 3-4 seconds in the streaming process. Interestingly, when I perform the same streaming using Qt 5.15.2, there is no such delay. I am aware that Qtmultimeadia module has undergone modifications since Qt 6. Is there a way to eliminate this streaming delay? Additionally, there are instances when the delay isn't observed, I am getting a Warning: "A lot of buffers are being dropped." and video is getting struck

      Item {

      MediaPlayer {
          id: player
          source: "rtsp://admin:admin123@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0"
          videoOutput:  cameraout
          onPlaybackStateChanged: function(newState) {
              console.log("playback state changed",playbackState)
          }
          onErrorOccurred: function(error, errorString) {
              console.log("error occured ",error, errorString);
          }
          audioOutput: AudioOutput {
              id: audioOutput
          }
          onHasVideoChanged: {
              console.log("has video changed ",hasVideo);
      
          }
          onBufferProgressChanged: {
              console.log("buffer changed ",bufferProgress,player.bufferedTimeRange())
          }
          onVideoOutputChanged: {
              console.log("videoOutPut changed",error,errorString,hasVideo,source)
          }
          onMediaStatusChanged: {
              if(player.mediaStatus ==MediaPlayer.NoMedia){
                  console.log("onMediaStatusChanged NoMedia",player.mediaStatus,MediaPlayer.NoMedia)
              }
              if(player.mediaStatus ==MediaPlayer.LoadingMedia){
                  console.log("onMediaStatusChanged LoadingMedia",player.mediaStatus,MediaPlayer.LoadingMedia)
      
              }
              if(player.mediaStatus ==MediaPlayer.LoadedMedia){
                  console.log("onMediaStatusChanged LoadedMedia",player.mediaStatus,MediaPlayer.LoadedMedia)
      
              }
              if(player.mediaStatus ==MediaPlayer.BufferingMedia){
                  console.log("onMediaStatusChanged BufferingMedia",player.mediaStatus,MediaPlayer.BufferingMedia)
      
              }
              if(player.mediaStatus ==MediaPlayer.StalledMedia){
                  console.log("onMediaStatusChanged StalledMedia",player.mediaStatus,MediaPlayer.StalledMedia)
      
              }
              if(player.mediaStatus ==MediaPlayer.BufferedMedia){
                  console.log("onMediaStatusChanged BufferedMedia",player.mediaStatus,MediaPlayer.BufferedMedia)
      
              }
              if(player.mediaStatus ==MediaPlayer.EndOfMedia){
                  console.log("onMediaStatusChanged EndOfMedia",player.mediaStatus,MediaPlayer.EndOfMedia)
      
              }
              if(player.mediaStatus ==MediaPlayer.InvalidMedia){
                  console.log("onMediaStatusChanged InvalidMedia",player.mediaStatus,MediaPlayer.InvalidMedia)
      
              }
          }
          onPlaybackRateChanged: {
              console.log("onPlaybackRateChanged ",player.playbackRate)
          }
          onPositionChanged: {
              console.log("onPositionChanged ",player.position)
          }
          onSourceChanged: {
              console.log("onSourceChanged ",player.source)
          }
      
      }
      
      
      VideoOutput {
          id: cameraout
          anchors.fill:parent
      }
      
      Rectangle{
          id: playrect
          width: 100
          height:width
          color: "green"
          anchors.bottom: parent.bottom
          anchors.left: parent.left
          MouseArea{
              anchors.fill: parent
              onClicked: {
                  player.source ="rtsp://admin:admin123@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0"
                  player.play()
                  console.log("play clicked")
              }
          }
      }
      Rectangle{
          id: pauserect
          width: 100
          height:width
          color: "red"
          anchors.bottom: parent.bottom
          anchors.right: parent.right
          MouseArea{
              anchors.fill: parent
              onClicked: {
                  player.source = ""
                  player.stop()
                  console.log("stopped")
              }
          }
      }
      

      }

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by
      #2

      @greed_14 https://forum.qt.io/topic/148589/mediaplayer-does-not-receive-stream-metadata/3?_=1693329743288

      G 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        @greed_14 https://forum.qt.io/topic/148589/mediaplayer-does-not-receive-stream-metadata/3?_=1693329743288

        G Offline
        G Offline
        greed_14
        wrote on last edited by
        #3

        @JoeCFD i did go through that link but there is nothing about delay in there.

        JoeCFDJ 1 Reply Last reply
        0
        • G greed_14

          @JoeCFD i did go through that link but there is nothing about delay in there.

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          @greed_14 I would upgrade Qt to 6.5 or above first.

          G 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @greed_14 I would upgrade Qt to 6.5 or above first.

            G Offline
            G Offline
            greed_14
            wrote on last edited by
            #5

            @JoeCFD yea but i need to get it done in Qt 6.3.1 as that's the requirement on the project i am working on.

            JoeCFDJ 1 Reply Last reply
            0
            • G greed_14

              @JoeCFD yea but i need to get it done in Qt 6.3.1 as that's the requirement on the project i am working on.

              JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #6

              @greed_14 If your OS is Linux, it is likely gstreamer is applied in Qt(guess) and maybe playbin is used for RTSP streaming. If my guess is correct, playbin has 2s delay by default. You can try it out from command line.

              command is:
              gst-launch-1.0 playbin -v uri=rtsp://admin:admin123@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0

              Since Qt does not offer enough controls over the pipelines, I do not use Qt multimedia module. Instead, I use raw gstreamer code with qml sink for rstp streaming in Linux.

              From SGaist in the link above: As Qt 6.5 switched the multimedia backend to ffmpeg.

              G 1 Reply Last reply
              0
              • JoeCFDJ JoeCFD

                @greed_14 If your OS is Linux, it is likely gstreamer is applied in Qt(guess) and maybe playbin is used for RTSP streaming. If my guess is correct, playbin has 2s delay by default. You can try it out from command line.

                command is:
                gst-launch-1.0 playbin -v uri=rtsp://admin:admin123@192.168.1.108:554/cam/realmonitor?channel=1&subtype=0

                Since Qt does not offer enough controls over the pipelines, I do not use Qt multimedia module. Instead, I use raw gstreamer code with qml sink for rstp streaming in Linux.

                From SGaist in the link above: As Qt 6.5 switched the multimedia backend to ffmpeg.

                G Offline
                G Offline
                greed_14
                wrote on last edited by
                #7

                @JoeCFD Hi as you have suggested there seems to be a delay with playbin.

                command 1:
                gst-launch-1.0 playbin -v uri=rtsp://127.0.0.1:8554/cam

                when i run the above command 1 which contains playbin there seems to be a 2-3s seconds delay.

                command 2:
                gst-launch-1.0 rtspsrc location="rtsp://127.0.0.1:8554/cam" latency=10 ! decodebin ! autovideosink

                whereas if i run command 2 there's not much visible delay.

                I have also been looking for alternative ways instead of using Qtmultimedia module cause there seems to be other issues related to memory with my version.Do you have any example or how i can use use raw gstreamer code with qml sink for rstp streaming without using Qtmultimedia module.

                JoeCFDJ 1 Reply Last reply
                0
                • G greed_14

                  @JoeCFD Hi as you have suggested there seems to be a delay with playbin.

                  command 1:
                  gst-launch-1.0 playbin -v uri=rtsp://127.0.0.1:8554/cam

                  when i run the above command 1 which contains playbin there seems to be a 2-3s seconds delay.

                  command 2:
                  gst-launch-1.0 rtspsrc location="rtsp://127.0.0.1:8554/cam" latency=10 ! decodebin ! autovideosink

                  whereas if i run command 2 there's not much visible delay.

                  I have also been looking for alternative ways instead of using Qtmultimedia module cause there seems to be other issues related to memory with my version.Do you have any example or how i can use use raw gstreamer code with qml sink for rstp streaming without using Qtmultimedia module.

                  JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by JoeCFD
                  #8

                  @greed_14 https://github.com/GStreamer/gst-plugins-good/tree/master/tests/examples/qt/qmlsink

                  in your command 2, you added 10ms delay which is too small for you to see any effect.

                  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