1. Documentation Wiki
 

Live Video Encoder - Low Latency Streaming

Overview:

*NOTES: *

  • End-to-end latency is dependent on all components in the workflow: capture, live encoder, upstream, server/cloud, downstream, player.
  • Latency is primarily based on stream buffers and streaming protocols used. Buffers can happen on all parts of a stream, encoder, streamer, server, CDN and player.
  • The new nanoStream H5Live player part of nanoStream Live Server or nanoStream Cloud can be used for plugin-free, browser-based low latency playback.

This document describes recommended settings to reduce overall end-to-end delay/latency in a video streaming/video chat application.

Choosing the right stream protocol

Lowest latency for client-server based streaming can be reached with RTMP or H5Live. With additional fine tuning, you can reach end-to-end-latency values below 1 second. For local area networks, UDP-TS has the lowest latency. Standard HLS, HDS, Smooth Streaming and MPEG DASH have high buffers by default and are not suitable for low latency applications.

Encoder Configuration

On Application/API level, nanoStream provides some functions to decrease end-to-end latency.

nanoStream Encoder Configuration

nanoStream supports some external and internal settings which may affect latency.

Usage of Baseline profile is recommended if suitable regarding the quality/bitrate scenario. Framerates should be as high as possible (20-25-30 fps). Lower than 15 fps might increase the overall latency, due to frame buffering.

Baseline Profile

Highest compatibility, low cpu/system requirements, low latency
Applications: Standard web streaming configuration for up to SD resolution, 15-30 fps and 0.1-1.5 Mbit video bitrate:

<code c++> nanoStream.SetConfig(“H264Profile”, “Baseline”); Baseline Profile supported by most devices and players nanoStream.SetConfig(“H264IFrameDistance”, “50”); Moderate GOP length nanoStream.SetConfig(“H264PFrameDistance”, “1”); No B-frames </code> ##### Main Profile Compatibility to most devices, low latency
Applications: Standard web streaming configuration for up to SD resolution, 15-30 fps and 0.1-1.5 Mbit video bitrate: <code c++> nanoStream.SetConfig(“H264Profile”, “Main”);
Main Profile nanoStream.SetConfig(“H264IFrameDistance”, “50”); Moderate GOP length nanoStream.SetConfig(“H264PFrameDistance”, “1”); No B-frames *nanoStream.SetConfig(“H264PFrameDistance”, “3”); * Optional: 2 B-frames (better quality, slightly higher latency) </code>

Performance settings

<code c++> nanoStream.SetConfig(“H264VlcMode”, “1”); CAVLC entropy coding mode nanoStream.SetConfig(“RateControl”, “1”); Strict constant bitrate nanoStream.SetConfig(“H264Quality”, “1”); Moderate quality, lower cpu requirements </code> ### Additional low-latency settings The Plugin Interface supports one function “LowDelayOn” which sets some internal buffer settings to achieve lower latency: :::c LowDelayOn() { SetConfig(“TcpNoDelay”,“0”); SetConfig(“OutBufferSize”,“0”); SetConfig(“SocketBufferSize”,“524288”); } RTMP Writer We recommend connecting to the server before starting the stream. On Windows, use StartConnect or IRTMPOptions::ConnectServer to establish the server connection before the stream is started (this is done automatically when using the plugin). TCP/IP Networking On the network level we recommend to use IRTMPOptions::SetTcpNoDelay(true) which disables the use of the nagle algorithm to decrease latency. For the plugin this can be set with the option “TcpNoDelay” for SetConfig(). Capture devices It is important that the latency/sample buffer size is not too big for the audio capture device pin. By default audio devices might use 500ms-1s. We recommend buffer sizes/audio latencies between 50ms-100ms. For Windows, this can be configured for the plugin using the option “AudioLatency” for SetConfig() or on DirectShow level with IAMBufferNegotiation::SuggestAllocatorProperties. ## Player Configuration The Player buffers have a high impact on latency. The best end-to-end latency for web streaming can be reached with RTMP. End-to-end latencies below 1-2 seconds are possible. Standard HLS and DASH are not designed for low latency streaming. With nanoStream H5Live, you have a solution for ultra-low latency browser based playback including HLS ### nanoStream H5Live The new nanoStream H5Live player can be used for plugin-free, browser-based low latency playback. ### Flash Player Configuration Flash Player net stream buffer should be set to a low value or 0: (e.g. jwplayer or others) NetStream buffer = 0.1 or 0 NOTE: Flash is an outdated technology, although still used for live video players. Please consider using nanoStream H5Live.
## Streaming Server Configuration With nanoStream Live Server or nanoStream Cloud, you will get a great user experience for low latency live streaming. Other servers like Wowza may need to be tuned for lower latency.

Please contact us for further information, additional support and consulting services are available upon request. http://www.nanocosmos.de © 2009-2017, nanocosmos gmbh

Further questions? Would you like a feature not available yet?
We can make it work for you based on our consulting and development / implementation services. Contact us.