chunk_size
The `chunk_size` directive specifies the size of the RTMP chunk that is used for streaming.
Description
The chunk_size directive in the NGINX RTMP module is a configuration option that allows you to define the maximum size of RTMP chunks sent over the network. This chunking mechanism is a fundamental part of the Real-Time Messaging Protocol (RTMP), used predominantly for live video and audio streaming. By adjusting the chunk size, you can optimize the performance of your streaming based on your specific use case and network conditions. In practice, smaller chunk sizes can result in lower latency but may increase overhead due to more frequent packet processing, while larger chunk sizes can enhance throughput but may introduce delay in delivery.
The value for the chunk_size directive must be configured as an integer, and it is specified in bytes, allowing for fine control over how data packets are transmitted. The directive can be applied within the RTMP server block for global settings or within specific application blocks for customized behavior per application. Proper tuning of the chunk size is important as it can affect various factors, including latency, stream stability, and resource usage. By default, a common chunk size is used, but setting this directive allows for adjustments based on the unique characteristics of the streaming environment.
Config Example
rtmp {
server {
listen 1935;
chunk_size 4000;
application live {
live on;
}
}
}If set too high, it may increase latency unnecessarily.
Setting the chunk size to a value that exceeds buffer limits can lead to dropped packets.
Not all clients may support custom chunk sizes, affecting compatibility.