exec_publish

The exec_publish directive in the NGINX RTMP module allows the execution of external commands upon the publication of a stream.

Syntaxexec_publish command [args];
Defaultnone
Context
Arguments1+

Description

The exec_publish directive is utilized within the context of the NGINX RTMP module, facilitating the execution of specified external commands or scripts whenever a stream is published. This directive enhances the streaming capabilities of NGINX by enabling triggers for additional operations such as encoding, archiving, or invoking any custom scripts that respond to the streaming event. Each argument supplied to the directive becomes part of the command executed at the time of publication, providing flexibility in handling live streams.

The directive accepts one or more arguments, where each represents a part of the command to be executed. The arguments can include paths to executables, options, and parameters that are necessary for the operation being performed. When a user initiates the publication of a stream, NGINX invokes the specified command, passing context information related to the stream, such as stream names, and session identifiers. This interaction occurs in real-time, allowing for immediate reactions to publishing events.

It's important to manage permissions and ensure that the NGINX user has the appropriate execution rights for the specified commands to prevent unauthorized access or failures during execution. Additionally, the commands executed can affect the overall performance and stability of the streaming server and should be well-optimized for production environments.

Config Example

application myapp {
    live on;
    exec_publish /usr/local/bin/myscript.sh $name $args;
}

Ensure the NGINX user has permissions to execute the specified commands.

Incorrect paths or parameters in the command can lead to failure without informative error messages.

Running heavy commands can affect performance; prefer lightweight scripts.

← Back to all directives