四、直播(Live)
01、live
语法:live on|off
上下文:rtmp, server, application
live模式开关,即一对多广播。
Toggles live mode i.e. one-to-many broadcasting.
live on;
02、meta
语法:meta on|copy|off
上下文:rtmp, server, application
设置元数据发送模式,设置为on,订阅者会收到包含元数据的重构数据包,包含预定义字段如宽、高等;
设置为copy,客户端会收到一份复制自发布者元数据块的数据包,包含标准的我特定的字段;
设置为off,将会停止发送任务RTMP元数据给订阅者; 默认值是 on。
Sets metadata sending mode. The value of on makes subscribers receive reconstructed metadata packets containing predefined fields like width, height etc.
The value of copy makes clients receive exact copy of publisher metadata block including both standard and specific fields.
The value of off turns off sending any RTMP metadata to subscribers. Defaults to on.
meta copy;
03、interleave
语法:interleave on|off
上下文:rtmp, server, application
切换交错模式,在这模式中,音频和视频会在同一个RTMP流中传输,默认值是 off。
Toggles interleave mode. In this mode audio and video data is transmitted on the same RTMP chunk stream. Defaults to off.
interleave on;
04、wait_key
语法:wait_key on|off
上下文:rtmp, server, application
使视频流以关键帧开始, 默认值为 off。
Makes video stream start with a key frame. Defaults to off.
wait_key on;
05、wait_video
语法:wait_video on|off
上下文:rtmp, server, application
禁用音频直到发送第一个视频帧。默认值是off,可以与wait_key组合,使客户端接收到视频关键帧时,同时收到其它所有相关数据;
但是这会使连接被延迟,你可以调整编码中关键帧的间隔以减少延迟。
Disable audio until first video frame is sent. Defaults to off. Can be combined with wait_key to make client receive video key frame with all other data following it.
However this usually increases connection delay. You can tune keyframe interval in your encoder to reduce the delay.
IE的最新版本,需要启用这个选项才能正常播放。
Recent versions of IE need this option to be enabled for normal playback.
wait_video on;
06、publish_notify
语法:publish_notify on|off
上下文:rtmp, server, application
发送NetStream.Play.PublishNotify 和 NetStream.Play.UnpublishNotify 给订阅者,默认值为off。
Send NetStream.Play.PublishNotify and NetStream.Play.UnpublishNotify to subscribers. Defaults to off.
publish_notify on;
07、drop_idle_publisher
语法:drop_idle_publisher timeout
上下文:rtmp, server, application
在规定的时间内卸掉那些空闲(无音频视频数据)的发布者连接,默认值为off,注意这个只对那些进入publish模式的连接才有效(发送publish命令后)。
Drop publisher connection which has been idle (no audio/video data) within specified time. Default is off.
Note this only works when connection is in publish mode (after sending publish command).
drop_idle_publisher 10s;
08、sync
语法:sync timeout
上下文:rtmp, server, application
同步音频和视频流,如果订阅者的带宽不足以来接收以发布者速率发送的数据,服务器会移除一些帧,这会引起同步问题,
当时间戳差超过指定为同步参数的值时,将会发送一个绝对帧来修正问题。默认值是 300ms。
Synchronize audio and video streams. If subscriber bandwidth is not enough to receive data at publisher rate, some frames are dropped by server.
This leads to synchronization problem. When timestamp difference exceeds the value specified as sync argument an absolute frame is sent fixing that. Default is 300ms.
play_restart off;
09、play_restart
语法:play_restart on|off
上下文:rtmp, server, application
如果启用,nginx-rtmp会在每一次发布者开始或结束推流时,发送NetStream.Play.Start 和NetStream.Play.Stop 给每个订阅者(用户);
如果禁用,订阅者只在回放(回放?)的开始和结束时才收到通知;默认值是 off。
If enabled nginx-rtmp sends NetStream.Play.Start and NetStream.Play.Stop to each subscriber every time publisher starts or stops publishing.
If disabled each subscriber receives those notifications only at the start and end of playback. Default is off.
play_restart off;
10、idle_streams
语法:idle_streams on|off
上下文:rtmp, server, application
如果禁用,nginx-rtmp将防止订阅者连接到空闲/不存在的直播流,并且在发布者断开时中断所有订阅者连接,默认值是on。
If disabled nginx-rtmp prevents subscribers from connecting to idle/nonexistent live streams and disconnects all subscribers when stream publisher disconnects. Default is on.
idle_streams off;
参考:https://github.com/arut/nginx-rtmp-module/wiki/Directives