I have developed a video chatting application,but the video is displayed with high latency.video is streamed over rtsp.how to reduce the delay in playing the rtsp stream?
How to reduce delay in playing rtsp live video stream in java using vlcj
Asked Answered
What video codec are you using? You should be able to reduce latency to <1s using following options:
- Add
:live-caching=0
to input handling options (e.g. when opening webcam) - Play around with codecs, for example change codec to mpeg-4 (seems to work better for my configuration where I have Android device as stream receiver)
- Add
:sout-mux-caching=10
(or some other low value) to stream options
With following line used to stream webcam video (notice: no audio) to my Android I was able to slightly reduce latency:
:sout=#transcode{vcodec=mp4v,vb=800,fps=30,scale=0.25,acodec=none}:rtp{sdp=rtsp://:8554/} :sout-keep :sout-mux-caching=10
Currently you have to configure like this
String[] options = {
":file-caching=0",
":network-caching=300",
":sout = #transcode{vcodec=x264,vb=800,scale=0.25,acodec=none,fps=23}:display :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep"};
mediaPlayer.playMedia(address, options);
The most important is network-caching=300
. Defualt is 1000 ms.
© 2022 - 2024 — McMap. All rights reserved.
:rtsp-mcast
). Other option is to use rtp over rtsp in tcp mode (vlc command option:rtsp-tcp
). – Flare:file-caching
,:rtsp-caching
etc. – Flare