RTSP stream delay which live stream a ip camera
-
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") } } }
}
-
@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=0Since 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.
-
@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/camwhen 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 ! autovideosinkwhereas 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.