buflen
The 'buflen' directive specifies the buffer length for RTMP streams in the NGINX RTMP module.
Description
The 'buflen' directive is used to set the maximum buffer length for RTMP stream data, which directly influences how much data can be buffered before being sent to clients. This value is critical for managing the balance between latency and memory usage during live stream processing. A larger buffer can help in accommodating network fluctuations and increase the media playback stability for clients but will consume more memory and potentially introduce higher latency. Conversely, a smaller buffer reduces latency but can lead to stuttering or interruptions in the media stream during variable network conditions.
In practice, you need to consider the expected network conditions and client capabilities when setting this directive. The buffer length can be tuned based on specific use cases, such as high-throughput live streaming or low-latency applications. The argument of the 'buflen' directive is specified in bytes and defines the size of the buffer to be used for managing the incoming RTMP stream data. Therefore, careful adjustments may be necessary to align the buffer size with the overall streaming performance goals. Furthermore, additional testing should be performed to find the optimal value that minimizes playback interruptions while not exceeding memory constraints.
Config Example
rtmp {
server {
listen 1935;
application live {
live on;
buflen 1048576; # Set buffer length to 1MB
}
}
}Setting 'buflen' too high can lead to increased memory usage.
Setting 'buflen' too low may cause playback issues during fluctuating network conditions.
Make sure to monitor stream performance after changing 'buflen'.