exec_pull
The exec_pull directive allows integration of external scripts or commands triggered on specific RTMP events.
Description
The exec_pull directive in the NGINX RTMP module permits users to specify one or more external commands or scripts to be executed when an RTMP stream is pulled. This is particularly useful for automating tasks during streaming events, such as transcoding streams or executing scripts for analytics. The directive can take multiple arguments, where each argument represents a command to be executed upon the relevant event.
When configured, the directive hooks into the lifecycle of RTMP streams. For instance, upon starting a stream pull, the specified command will be executed. This allows for dynamic responses based on streaming events, facilitating integrations with various services or custom tools. The execution environment typically inherits relevant environment variables, and developers can pass parameters related to the stream such as stream name or client details.
It's crucial to ensure that commands are designed to handle concurrent executions gracefully, especially when multiple streams are involved. Proper error handling and logging can also assist in diagnosing issues during the command execution process, ensuring that any failures do not adversely affect the streaming service.
Config Example
application live {
live on;
exec_pull /path/to/script.sh arg1 arg2;
}Ensure the specified script or command has the correct permissions to execute; otherwise, it may fail silently.
Commands executed must be designed to handle concurrency since multiple streams can trigger them.
If the command exits with an error, it may disrupt the streaming process unless properly handled.