【nginx-rtmp】05、指令(Directives)之 核心(Core)

一、核心(Core)

01、rtmp

語法:rtmp {}

上下文:root

一個包括所有RTMP設置的塊
The block which holds all RTMP settings


02、server

語法:server {}

上下文:rtmp

定義一個RTMP服務器實例
Declares RTMP server instance

rtmp {
  server {
  }
}



03、listen

語法:listen (addr[:port]|port|unix:path) [bind] [ipv6only=on|off] [so_keepalive=on|off|keepidle:keepintvl:keepcnt|proxy_protocol]

上下文:server

添加監聽套接字到NGINX,用來接受RTMP請求
Adds listening socket to NGINX for accepting RTMP connections

server {
    listen 1935;
}



04、application

語法:application name { ... }

上下文:server

創建RTMP應用,跟http的application不一樣,如名稱不能用來做匹配
Creates RTMP application. Unlike http location application name cannot be a pattern.

server {
    listen 1935;
    application myapp {
    }
}



05、timeout

語法:timeout value

上下文:rtmp, server

套接字超時時間,主要用於寫操作,大多數情況下RTMP模塊不期望除發佈者套接字外的其它套接字處於活躍狀態,
如果你想能過中止套接字來快速斷開連接,你可以使用一些 active 工具,如 keepalive 或者 RTMP ping,默認是1分鐘超時。
Socket timeout. This value is primarily used for writing. Most of time RTMP module does not expect any activity on all sockets except for publisher socket.
If you want broken socket to get quickly disconnected use active tools like keepalive or RTMP ping. Default is 1 minute.

timeout 60s;



06、ping

語法:ping value

上下文:rtmp, server

定義RTMP執行ping功能的間隔時間,設置爲0將會關閉ping功能,ping 這個協議功能是用來檢查活動連接的,
它會發送一個特殊的數據包到遠程相關服務,並且等待返回內容,如果在ping_timeout指令定義的超時時間內沒收到返回,當前連接會關閉;
默認的ping間隔值爲1分鐘,默認的等待超時是30秒。
RTMP ping interval. Zero turns ping off. RTMP ping is a protocol feature for active connection check.
A special packet is sent to remote peer and a reply is expected within a timeout specified with ping_timeout directive.
If ping reply is not received within this time then connection is closed. Default value for ping is 1 minute. Default ping timeout is 30 seconds.

ping 3m;
ping_timeout 30s;



07、ping_timeout

語法:ping_timeout value

上下文:rtmp, server

參考上面的 ping指令的描述
See ping description above.


08、max_streams

語法:max_streams value

上下文:rtmp, server

設置RTMP流的最大值,多個數據流會被複用到單個數據流中,
不同的通道用來發送命令、音頻、視頻等。默認值爲32,這個值在通常情況都適用。
Sets maximum number of RTMP streams. Data streams are multiplexed into a single data stream.
Different channels are used for sending commands, audio, video etc. Default value is 32 which is usually ok for many cases.

max_streams 32;



09、ack_window

語法:ack_window value

上下文:rtmp, server

設置RTMP確認框的大小,定義在某個peer發送確認數據包到遠端時的字節數,默認值爲 5000000。
Sets RTMP acknowledge window size.
It's the number of bytes received after which peer should send acknowledge packet to remote side.
Default value is 5000000.

ack_window 5000000;



10、chunk_size

語法:chunk_size value

上下文:rtmp, server

多個流複用的塊的最大值,默認是4096,這個值越大,CUP的消耗越大,這個值不能小於128。
Maximum chunk size for stream multiplexing. Default is 4096.
The bigger this value the lower CPU overhead. This value cannot be less than 128.

chunk_size 4096;



11、max_queue

(官方文檔還沒寫)


12、max_message

語法:max_message value

上下文:rtmp, server

輸入的數據的message(信息報文?)的最大值,所有輸入的數據分割爲報文(然後進一步分割爲塊),
報文在等待處理完成前會放在內存,理論上傳入的消息可能非常大,這會影響服務器性能,默認值爲1M對於大多數情況已經足夠了。
Maximum size of input data message. All input data comes split into messages (and further in chunks).
A partial message is kept in memory while waiting for it to complete.
In theory incoming message can be very large which can be a problem for server stability.
Default value 1M is enough for many cases.


13、buflen

語法:buflen time

上下文:rtmp, server

設置默認緩衝區長度?通常客戶端在播放前會發送 set_buflen 命令並重置這個值,默認是 1000ms。
Sets default buffer length. Usually client sends RTMP set_buflen command before playing and resets this setting. Default is 1000 ms.

buflen 5s;



14、out_queue

(官方文檔還沒寫)

15、out_cork

(官方文檔還沒寫)



參考:https://github.com/arut/nginx-rtmp-module/wiki/Directives

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章