四、直播(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