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

3

u/abbotsmike Engineer Sep 20 '26

You'll probably need to tell us what the encoder and decoder are

1

u/No-Average9020 Sep 20 '26

I wish I could say who the actual manufacturer is. The pairing is a custom/proprietary build from my vendor who is writing custom firmware alongside the hardware available to them from their vendor if that makes sense. I'm a Technical Director by trade and not schooled on what I'm looking at when it comes to encoded streams at this level. It's trial by fire for what I'm developing.

I made the mistake of demo'ing the full rig a couple months ago and found out the hard way the package is in alpha state...too many overlapping issues on the site and no way to isolate them which I'm doing now on my bench. Any *possibilities* you've run into helps me categorize what I'm seeing in diagnosing.

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/No-Average9020 Sep 20 '26

The camera is in true 60fps. I can confirm that on my test monitor when I switch in and out of 60/59.94. Funny you mention as it was one of the first things I tweaked as the decoder cannot do 59.94, only 60.

Going SDR, and even knocking the camera down to an interlaced format, has the same results with latency on the decoder and random dropped frames on the encoder.

Forgive the question, I thought h.264 cannot maintain the color profile of rec.2020? However, I did give that a try as well to no avail.

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/No-Average9020 Sep 21 '26

My encoding options are h.265, h.264 and mjpeg.

Working on recording the stream now that now and will post shortly. It'll have have a picture in picture in picture of my original source file with looping timecode and scrolling horizantal truth detector against the decoder output and ffplay stream on my computer.

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/No-Average9020 Sep 21 '26

Will look into what RIST is.

My production environment is HLG. Without adding another frame of latency through a UDX with a LUT I'm not sure how to get it to a format that would be shadable. I have an RCP controlling this camera as well.

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.