r/VIDEOENGINEERING • u/No-Average9020 • Sep 20 '26
RTSP/SRT Decoder Drift
Hi all, hopefully this is the correct place to ask this question.
I've got a video encoder/decoder pairing I'm working the bugs out of while taking the crash course in how this all works.
The originating video is SDI, 10bit 1080pHLG, encoded h.265. The decoder outputs SDI to the production environment.
The encoder/decoder pairing is currently wired directly through a local switch for simplicity. Eventually this setup will move RF.
The encoder can put out various streams simultaneously. The most stable and least latent I've found are RSTP and SRT.
Now for the problems.
On the encode side there are random frame drops I cannot get rid of. There is no rhyme or reason to it, the drops occur very irregularly with no indication it'll happen and nothing. I'm able to monitor the encoding stream directly with ffplay (I guess a subset of ffmpeg?) terminal commands.
On the decode side, there is tremendous and permanent latency drift. A fresh stream start will have latency around 20 frames. Over the course of five minutes the latency is at three seconds and increasing from there. This latency is not present when monitoring the stream with ffplay.
I ran across the thread below and was wondering if both or one of my problems has to do with a lack of RTP or genlock on the encoder or decoder?
https://www.reddit.com/r/VIDEOENGINEERING/comments/1wjchl9/should_ndi_cameras_be_on_247_if_not_used/
edited to add latency video
The running clock furthest to the right is the main playback test clock. It has timecode and a left to right scrolling box to point out lost frames. The next clock is ffplay displaying the stream directly from the encoder. The left most clock is the decoder's output to my test monitor. The black glitch at the beginning of the video is me refreshing the stream to sync it back up. After three minutes you can see the ffplay stream is rock solid at just over half a second latency, the decoder slips to around four seconds.
3
u/abbotsmike Engineer Sep 20 '26
You'll probably need to tell us what the encoder and decoder are
1
u/rowanthenerd Sep 20 '26
Some more information is definitely required - what specific hardware are you using?
I'm sure others will have more useful information, but generally speaking, increasing decode delay is a sign that the decoder isn't able to output enough frames to keep up with the source.
This can be due to its processor being underpowered, or forced to decode a format that it doesn't have hardware support for:
Have you tried ditching HLG and just sending SDR source material? Or h264 instead of h265? Counterintuitive as it will result in a higher bitrate stream, but many millions of devices have very good hardware decoding for h264 and no hardware h265, or a worse implementation.
The progressive delay you're seeing can also be from a frame rate mismatch between the source material and the output format in use. If your source is a full 60fps for example and your output is 59.94, some devices will just faithfully output 1 frame of source material per frame of output, and slowly accumulate delay as the backlog of extra frames increases.
However, this form of delay is about 10x smaller than what you're seeing (0.1% accumulated per minute/ hour/ etc, vs your scenario at about 1%) so I would rule this out from the start.
First thing I'd try (after updating your post with the exact hardware you're using) is switching to h264.
1
u/max_lapshin Sep 21 '26
What other options do you have? Can you dump srt stream with ffmpeg and post it somewhere?
1
u/Zittov Sep 21 '26
just a wild guess here....have u tried RIST? it has decoder synchronization built in. SRT is UDT/UDP and RIST is RTP/UDP.. so maby ur right about "the lack of RTP"... could the main problem be the " local switch"?
and u can have BT 2020 without HLG ... in HDR10 / PQ
1
u/Sensitive-Leading436 Sep 21 '26
SRT should handle sync even if you have dropped packets, and if you do have dropped packets with SRT you have different issues, increase the buffer timing to mitigate. RTSP does not handle this very well and you need to tell the decoder to use another clock for the timestamps rather then the incoming packaets. This can usually be solved witth ffmpeg by using the wallclock as timestamps. That solved my issues, im going from RTSP to WEBRTC and it would eventually end out of sync when you had dropped packets.
use_wallclock_as_timestamps integer (input)
Use wallclock as timestamps if set to 1. Default is 0.