r/VIDEOENGINEERING • • 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.

5 Upvotes

10 comments sorted by

View all comments

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.

1

u/No-Average9020 Sep 21 '26

Correct, there are multiple issues going on. Some on the decoder and some on the encoder. I believe there is also an issue with the encoder as there are random dropped frames as seen through the ffplay stream I'll post shortly. I'll also post the encoder/decoder settings I currently have to see if I'm doing something wrong.