exec_record_done
The exec_record_done directive specifies commands to be executed when a recording session is completed in the NGINX RTMP module.
Description
The exec_record_done directive allows users to define command(s) that NGINX will execute once a recording stream is finalized. This functionality can be particularly useful for performing actions such as processing or archiving the recorded file after the recording session concludes. The arguments passed to this directive are interpreted as command strings that NGINX will run via a system shell. It can accept one or more command strings, enabling flexibility in command execution. For instance, users could invoke FFmpeg for transcoding, or trigger a custom script to handle post-processing tasks.
When utilizing this directive, it is essential to ensure that the commands provided are correctly formatted and accessible within the NGINX execution environment. If commands fail, it can lead to silent failures which may complicate troubleshooting. The execution context is the server process, thus it is crucial to ensure proper permissions and execution paths are set for the commanded operations. Additionally, since the commands execute upon the termination of a recording session, they can run asynchronously, which must be factored into any dependent operations that are executed afterward.
Errors during command execution will not affect the integrity of the recording but may prevent additional expected work from being completed. Therefore, it's advisable to include robust error handling in the invoked commands.
Config Example
application live {
live on;
record all;
exec_record_done /usr/local/bin/post_process.sh;
}Commands must be fully qualified with paths to prevent execution failures due to environment path issues.
Ensure that the NGINX user has necessary permissions to execute the specified commands or scripts.
Be cautious with the output and return values of executed scripts, as errors do not disrupt the recording process.