一、核心(Core)
01、rtmp
语法:rtmp {}
上下文:root
一个包括所有RTMP设置的块
The block which holds all RTMP settings
02、server
语法:server {}
上下文:rtmp
定义一个RTMP服务器实例
Declares RTMP server instance
rtmp {
server {
}
}
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;
}
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 {
}
}
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;
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