Nginx-rtmp-module instruction Detailed

Source: Internet
Author: User
Tags socket terminates
Translation order: As of Jul 8th, 2013, the latest Nginx RTMP module nginx-rtmp-module instruction is released.

Core rtmp
Syntax: rtmp {...}
Context: root
Description: A block that holds all RTMP configurations.


server
Syntax: server {...}
Context: rtmp
Description: Declare an RTMP instance.
rtmp {
  server {
  }

}


listen
Syntax: listen (addr [: port] | port | unix: path) [bind] [ipv6only = on | off] [so_keepalive = on | off | keepidle: keepintvl: keepcnt]
Context: server
Description: Add a listening port to NGINX to receive RTMP connections.
server {
    listen 1935;

}


application
Syntax: application name {...}
Context: server
Description: Create an RTMP application. The pattern of application name is not similar to http location.
server {
    listen 1935;
    application myapp {
    }

}


timeout
Syntax: timeout value
Context: rtmp, server
Description: Socket timed out. This value is mainly used when writing data. In most cases, the RTMP module does not expect ports other than the publisher port to be active. If you want to close the socket quickly, you can use keepalive or RTMP ping. timeout defaults to 1 minute.
timeout 60s;

ping syntax: ping value
Context: rtmp, server
Description: RTMP ping interval. A zero value turns ping off. RTMP ping is a protocol feature for checking active connections. Send a special packet to the remote connection and expect a reply within the time specified by the ping_timeout instruction. If no ping reply is received within this time, the connection is dropped. The ping default is one minute. ping_timeout defaults to 30 seconds.
ping 3m;
ping_timeout 30s;

ping_timeout syntax: ping_timeout value
Context: rtmp, server
Description: Please refer to the ping description above.

max_streams syntax: max_streams value
Context: rtmp, server
Description: Sets the maximum number of RTMP streams. The data streams are integrated into a single data stream. Different channels are used to send commands, audio, video, etc. The default value is 32, which is suitable for most situations.
max_streams 32;

ack_window syntax: ack_window value
Context: rtmp, server
Description: Set the RTMP confirmation window size. This is the number of bytes that the peer should receive after sending an acknowledgement packet to the far end. The default value is 5000000.
ack_window 5000000;

chunk_size syntax: chunk_size value
Context: rtmp, server
Description: The largest block size for stream integration. The default value is 4096. The higher this value is set, the smaller the CPU load. This value cannot be lower than 128.
chunk_size 4096;

max_queue syntax: max_queue value
Context: rtmp, server
Description: The maximum size of the input data message. All input data is split into messages (then further split into blocks). Messages are stored in memory before processing is complete. In theory, if the received message is large, it may affect the stability of the server. The default value of 1M is sufficient for most situations.
max_message 1M;
out_queue
out_cork


Access
allow
Syntax: allow [play | publish] address | subnet | all
Context: rtmp, server, application
Allow publishing / playing from specified addresses or all addresses. The order of the allow and deny directives is optional.
allow publish 127.0.0.1;
deny publish all;
allow play 192.168.0.0/24;
deny play all;
deny
Syntax: deny [play | publish] address | subnet | all
Context: rtmp, server, application
Description: Refer to the description of allow.


Exec exec
Syntax: exec command arg *
Context: rtmp, server, application
Description: Defines an external command with parameters to be executed when each stream is published. The process terminates when publishing ends. The first parameter should be the full path of the binary executable. There are no assumptions as to what this process will do. But this feature is useful when using ffmpeg for stream conversion. FFmpeg is assumed to connect to nginx-rtmp as a client and then convert the stream to nginx-rtmp as a publisher output. Substitutions similar to $ var / $ {var} can be used on the command line:
* $ name-the name of the stream.
* $ app-application name.
* $ addr-client address.
* $ flashver-client flash version.
* $ swfurl-client swf url.
* $ tcurl-client tc url.
* $ pageurl-client page url.
A shell-style redirection can be defined in the exec instruction for writing output and receiving input. Support as follows
* Truncate output> file.
* Additional output >> file.
* The redirection descriptor is similar to 1> & 2.
* Enter <file.
The following ffmpeg call transcodes the input stream into an HLS-ready stream (H264 / AAC). To run this example, FFmpeg must be compiled to support libx264 & libfaac.
application src {
    live on;
    exec ffmpeg -i rtmp: // localhost / src / $ name -vcodec libx264 -vprofile baseline -g 10 -s 300x200 -acodec libfaac -ar 44100 -ac 1 -f flv rtmp: // localhost / hls / $ name 2> > /var/log/ffmpeg-$name.log;
}

application hls {
    live on;
    hls on;
    hls_path / tmp / hls;
    hls_fragment 15s;
}

exec_static syntax: exec_static command arg *
Context: rtmp, server, application
Description: Similar to the exec instruction, but will run the defined command when nginx starts. Because (at startup) there is no session context, replacement is not supported.
exec_static ffmpeg -i http://example.com/video.ts -c copy -f flv rtmp: // localhost / myapp / mystream;

exec_kill_signal syntax: exec_kill_signal signal
Context: rtmp, server, application
Description: Sets the process termination signal. The default is kill (SIGKILL). You can define it as a numeric or symbolic name (POSIX.1-1990 signals).
exec_kill_signal term;
exec_kill_signal usr1;
exec_kill_signal 3;

respawn syntax: respawn on | off
Context: rtmp, server, application
Description: If the respawn child process is opened, the conference will continue when the process terminates. On by default.
respawn off;

respawn_timeout syntax: respawn_timeout timeout
Context: rtmp, server, application
Description: Set the respawn timeout before starting a new child instance. The default is five seconds.
respawn_timeout 10s;

exec_publish syntax: exec_publish command arg *
Context: rtmp, server, application
Description: Specifies an external command with parameters triggered by a publish event. The return code is unparsed. This can be replaced with exec. In addition, the args variable supports holding query string parameters.

exec_play syntax: exec_play command arg *
Context: rtmp, server, application
Description: An external command with parameters triggered by the specified playback event. The return code is unparsed. The replacement list is the same as exec_publish.

exec_play_done syntax: exec_play_done command arg *
Context: rtmp, server, application
Description: Specify an external command with parameters triggered by the end of playback event. The return code is unparsed. The replacement list is the same as exec_publish.

exec_publish_done syntax: exec_publish_done command arg *
Context: rtmp, server, application
Description: An external command with parameters triggered by the specified end of publication event. The return code is unparsed. The replacement list is the same as exec_publish.

exec_record_done syntax: exec_record_done command arg *
Context: rtmp, server, application, recorder
Description: Specifies an external command with parameters that is triggered when the recording ends. Support for exec_publish substitution and additional variables path and recorder are supported here.
# track client info
exec_play bash -c "echo $ addr $ pageurl >> / tmp / clients";
exec_publish bash -c "echo $ addr $ flashver >> / tmp / publishers";

# convert recorded file to mp4 format
exec_record_done ffmpeg -y -i $ path -acodec libmp3lame -ar 44100 -ac 1 -vcodec libx264 $ path.mp4;


Live live
Syntax: live on | off
Context: rtmp, server, application
Description: Switch live broadcast mode, that is, one-to-many broadcast.
live on;

meta syntax: meta on | off
Context: rtmp, server, application
Description: Switch to send metadata to the client. The default is on.
meta off;

interleave syntax: interleave on | off
Context:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.