buffer

The `buffer` directive controls the size of the internal buffer for DASH streaming in the NGINX RTMP module.

Syntaxbuffer size;
Defaultnone
Context
Arguments1

Description

The buffer directive in the NGINX RTMP module is designed to optimize the buffering behavior when serving Dynamic Adaptive Streaming over HTTP (DASH) content. By specifying this directive in the configuration, you can determine the amount of data to be temporarily stored in the buffer before it is streamed to clients. This buffering mechanism is crucial for providing a smooth streaming experience and helps manage network traffic effectively, especially during high-load scenarios.

When a client requests a stream, the server can begin sending data as it becomes available, while additional data continues to be buffered. This allows for better handling of variable network conditions and minimizes disruptions caused by slow data transmission. The parameter for the buffer directive specifies the size in bytes, enabling the server to pre-load a certain amount of content ahead of time before delivering it to the client. Adjusting this value can optimize performance based on network quality and expected viewer demand.

In practical terms, if the buffer size is set too low, users may experience buffering as the application struggles to keep pace with the data being requested. Conversely, setting the buffer size excessively high can lead to increased latency and resource consumption. Thus, it's essential to find the right balance for your specific use case and streaming requirements.

Config Example

rtmp {
    server {
        listen 1935;

        application live {
            live on;
            buffer 1048576;  # Set buffer size to 1 MB
        }
    }
}

Ensure the buffer size is appropriate for your network conditions; too small can lead to interruptions.

Excessive buffer sizes can increase latency and use unnecessary memory resources.

Configuration changes may require reloading or restarting the NGINX service to take effect.

← Back to all directives