on_record_done
The `on_record_done` directive allows you to specify a callback function to be executed when a recording of a stream is completed.
Description
The on_record_done directive is part of the NGINX RTMP module which provides the ability to perform live streaming and various media handling operations. When you enable this directive in your server configuration, it requires an argument that specifies the command or a script to be executed upon the completion of recording a stream. This is particularly useful for scenarios where you want to perform post-processing tasks such as transcoding, archiving, or notifications after the stream recording has ended.
The parameter passed to on_record_done must be a valid executable command or script that NGINX can access, and it will execute this command using the same context as the live stream. Make sure that the command operates correctly within the permissions and environment established by NGINX, as improper configuration can lead to failure in executing the command. This feature enhances the flexibility of managing recorded streams by integrating external processing tools, allowing for automation of workflows in media handling.
To use the on_record_done directive, it should be placed in the appropriate context where streams are managed, such as within an application block that handles RTMP streaming. The directive will then act on any completed recordings that occur within that context, helping administrators to manage recordings effectively and efficiently.
Config Example
application live {
live on;
record all;
record_path /tmp/recordings;
on_record_done /usr/local/bin/post_process_script.sh;
}Ensure that the command specified has the correct permissions and environment to execute properly.
If the command has dependencies (like scripts or executables), confirm they are accessible to the NGINX user.
Using complex commands without proper output handling may lead to unexpected results or failures. Beware of output buffering issues that can affect script execution.