'Reducing outbound transfer in nginx rtmp server

I have a nginx-rtmp server for real time hls streaming with three rtmp stream running. Right now all the hls are streaming are at 3-4mbps, is there any i can restrict the outbound data transfer rate to 1-2mpbs using directives in nginx.

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application live {
            notify_method get;
            live on;
            hls on;
            hls_path /nginx/hls/;
            hls_fragment 3;
            hls_playlist_length 60;
            drop_idle_publisher 10s;
            meta copy;
            hls_variant _low BANDWIDTH=166000;
            hls_variant _mid BANDWIDTH=244000;
        }
    }
}

http {
    sendfile off;
    tcp_nopush on;
    directio 512;
    default_type application/octet-stream;
    
    server {
        listen 8080;
        location / {
            add_header 'Cache-Control' 'no-cache';
            add_header 'Access-Control-Allow-Origin' '*' always;
            add_header 'Access-Control-Expose-Headers' 'Content-Length';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
            if ($request_method = 'OPTIONS') {
                add_header 'Access-Control-Max-Age' 1728000;
                add_header 'Content-Type' 'text/plain charset=UTF-8';
                add_header 'Content-Length' 0;
                return 204;
            }           
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }       
           root /nginx/hls/;
           #root /nginx/;
        }
        
    }
    
}

Thanks in advance


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source