Identify per component latency on livestream services

265 views Asked by At

I am using below pipeline for livestreaming, I am able to find the end-to-end latency which is about 30-35s, is there a way I can identify per component latencies, like the latency at MediaLive and latency at MediaPackage?

OBS (Open broadcast) --RTMP--> MediaLive --HLS-> MediaPackage --HLS--> Cloudfront -> video.js player
1

There are 1 answers

0
Winlin On

The latency is everywhere, so it's important to find out which components introduced the latency. However, each component will introduce a piece of latency:

  • RTMP: The latency is about 1s, if the network is ok.
  • HLS: The latency is about 3~5s, depends on the ts duration.

I guess the minimum latency of your system, is about 5~10s. Where encoder takes 0.8s, RTMP is 1s, HLS is 1~3s, CDN is about 1~3s, player is 1~3s. Please check it by some tools bellow.

Use a small tool online stopwatch or others similar, then use OBS window capture to capture the stopwatch in livestream, and play the RTMP/HLS stream from MediaLive, and HLS from cloudfront, you will get the latency of each system.

You can also use FFmpeg to replace OBS to publish RTMP stream, with a filter to show the timestamp, please read SRS#2742.

Please use ffplay, flv.js, hls.js to play the stream, NEVER use VLC which has a huge latency itself.

There are some tips after you find the latency:

  • For RTMP server, disable the gop cache.
  • For HLS, use smaller ts duration like 1~2s.
  • For encoder(OBS), use Main or Baseline, with smaller gop 1s, and tune with zerolatency.
  • If possible, use WebRTC to deliver the stream, the latency is about 200ms.

Please NEVER apply these settings, unless you finger out where the latency is introduced.