Skip to main content

Latency & latency control modes

nanocosmos delivers live streams with ultra-low latency from your encoder to every viewer. This page explains what latency to expect, what affects it, and how to choose the right latency control mode in the nanoStream Player.

What latency to expect​

Latency here means end-to-end ("glass-to-glass") delay: the time from the camera capturing a frame to that frame appearing on the viewer's screen.

With MOQ playback, latency is typically sub-second: under 500 ms in good networks, or even lower.

It depends on the whole end-to-end workflow, including your encoder configuration, both network legs and the latency control mode. To see the real values for your streams, measure them (see Measure latency). Contact us to fine-tune the latency for your workflow.

What affects latency​

FactorRecommendation
Keyframe interval (GOP)Set to 2 seconds. Longer intervals increase latency and startup time.
B-framesDisable for the lowest latency.
Rate controlUse CBR (constant bitrate).
Upload bandwidthKeep the bitrate well below your available upload bandwidth.
Adaptive Bitrate StreamingABR gives better reach on variable networks with slightly higher latency than a single passthrough stream.
Distance and network qualityIngest and playback are geo-load-balanced to the nearest region automatically. Poor viewer networks add buffering.
Player latency control modeSee below.

Encoder settings are covered in RTMP ingest & encoder settings.

Latency control modes​

The nanoStream Player continuously adjusts its buffer to stay close to the live edge. The playback.latencyControlMode setting decides how aggressively it does that. All three modes are low-latency modes; the value is a strategy, not a latency target in seconds.

VideoHow to set up optimal latency modes for streaming
ValueBehaviourUse it when
'classic'Threshold-based buffer control. Well established and reliable. The only mode that uses custom tweaks.buffer values.You need maximum stability or want to tune the buffer yourself.
'balancedadaptive'Adapts to current stream and network conditions. Reaches and holds a lower latency than classic while keeping playback smooth. Default in nanoStream Player 5.x.Most use cases.
'fastadaptive'Adapts like balancedadaptive with lower operating points. Tracks the live edge most aggressively.Lowest latency matters most, for example live auctions or betting.

These are the only valid values. Any other value isn't a valid latency control mode.

note

The default changed with nanoStream Player 5.0: up to 4.x it was 'classic', since 5.0 it is 'balancedadaptive'. If you upgraded and set nothing, your player now uses 'balancedadaptive'.

Configuration​

var config = {
source: { /* ... */ },
playback: {
latencyControlMode: 'balancedadaptive', // 'classic' | 'balancedadaptive' | 'fastadaptive'
faststart: true
}
};

In the iframe embed and the demo player, pass it as a URL parameter:

https://demo.nanocosmos.de/nanoplayer/embed/2.0.0/nanoplayer.html?group.id=<STREAM_GROUP_ID>&playback.latencyControlMode=fastadaptive

Platform support​

This table applies to H5Live playback (WebSocket and HLS):

Platformclassicbalancedadaptivefastadaptive
Desktop (Windows, macOS, Linux): Chrome, Edge, Firefox, Safari, Chromium-basedYesYesYes
Android: Chrome, Firefox, Chromium-based, WebViewsYesYesYes
iOS / iPadOS: Safari, Chrome, Firefox, WebViewsYesYesFalls back to balancedadaptive

On platforms that don't support adaptive modes, the player falls back to 'classic' automatically. You don't need browser-specific configuration.

With MOQ, all three modes apply on all platforms. They set how much the player buffers: classic the most, fastadaptive the least.

Fast start​

playback.faststart (default true since player 5.0) starts playback close to the live edge for a faster join. Keep it on unless support advises otherwise.

Buffer tweaks (classic mode)​

warning

Keep the default buffer settings. Wrong values cause freezes or a loop of buffering and resuming. Use the adaptive modes without tweaks.buffer, and contact support before changing these values.

tweaks.buffer mainly affects the 'classic' mode. The player applies these defaults internally (values in seconds):

KeyDefaultMeaning
tweaks.buffer.min0.2If the buffer drops to this value during playback, the player buffers until it reaches start.
tweaks.buffer.start0.5Playback starts at this buffer level.
tweaks.buffer.target1.2The level the player aims for when the buffer reaches limit or max.
tweaks.buffer.limit1.7Above this level, the player smoothly reduces latency towards target.
tweaks.buffer.max8.0Absolute maximum. When reached, the player seeks hard to target.

If you change them, the values must ascend (min < start < target < limit < max), and the gaps between min and start, min and target, and target and limit must be large enough. Values too close together (for example min: 0.2, target: 0.3) disrupt buffering. In the iframe embed, pass tweaks as a complete set.

var config = {
playback: { latencyControlMode: 'classic' },
tweaks: {
buffer: { min: 0.2, start: 0.5, target: 1.2, limit: 1.7, max: 8.0 }
}
};

Measure latency​

  • In the player: the onStats event delivers data.stats.buffer.delay (current, avg, min, max) and, since player 4.14.1, data.stats.buffergoal with the values the latency control works with. See Events & error codes.
  • In nanoStream Analytics: the MoQ page shows average and median player latency for MOQ playbacks; the H5Live page shows average and median buffer length, which drives latency for WebSocket/HLS playbacks. See Metrics explained.

Troubleshooting​

SymptomCheck
Latency higher than expectedKeyframe interval 2 s, B-frames off, CBR. Then check the latency control mode and that no custom tweaks.buffer is set.
Frequent buffering with fastadaptiveSwitch to balancedadaptive; the viewer's network may not sustain the lower operating point.
fastadaptive behaves like balancedadaptive on iPhoneExpected: iOS supports balancedadaptive only.
Latency grew after enabling ABRExpected to a small degree; compare with a passthrough stream. See Adaptive Bitrate Streaming.

Next steps​