Execute custom logic via shell script after recording a stream with Wowza streaming engine
The OnRecord module for Wowza Streaming Engine™ media server software can be used to execute custom logic after the recording of a stream has been completed. This means you need not bother about writing complex logic in java to do something after the recording has been completed. Some of the common tasks undertaken after recording a stream are uploading it to the cloud, post-processing it to generate alternate media formats via FFmpeg, or simply notifying a remote server of recording completion. The OnRecord module simplifies things for you by wiring the Wowza application’s record complete event to an executable shell script/batch file on the same system. You can then use this external script to implement custom logic in place or just call a server-side script from there.
Wowza Streaming Engine 4.8.x or later is required.
- Download the latest release of rtmpworld-wse-plugin-onrecord & rtmpworld-wse-utilities shared library builds/archives.
- Extract the contents from the downloaded (zipped) packages.
- Rename extracted files lib/rtmpworld-wse-plugin-onrecord-x.x.x.jar to lib/rtmpworld-wse-plugin-onrecord.jar & rtmpworld-wse-utilities-x.x.x.jar to rtmpworld-wse-utilities.jar
- Then copy the lib/rtmpworld-wse-plugin-onrecord.jar & rtmpworld-wse-utilities.jar file from the package to the lib folder in your Wowza Streaming Engine installation ([install-dir]/lib).
- Restart Wowza Streaming Engine.
NOTE: rtmpworld-wse-utilities shared library(rtmpworld-wse-utilities.jar) is a dependency for all our modules. It is not a module in itself. It simply contains resources that are used by our modules at runtime. If you are using multiple modules from us then you should copy this file just once into the lib folder of your Wowza Streaming Engine installation ([install-dir]/lib).
To enable this module, add the following module definition to your application configuration. See Configure modules for details.
|NAME||DESCRIPTION||FULLY QUALIFIED CLASS NAME|
|ModuleOnRecordScript||Enables you to trigger a shell script/batch file on record completion||com.rtmpworld.server.wowza.plugins.ModuleOnRecordScript|
After enabling the module, you can adjust the default settings by adding the following properties to your application. See Configure properties for details.
|/Root/Application||onrecordScriptWorkingDir||String||D:/wowzascripts||The absolute path of the working directory.|
|/Root/Application||onrecordRecordCompleteScript||String||D:/wowzascripts/record_complete.bat||The absolute path of the script to be executed on record complete event (when file write finishes).|
|/Root/Application||onrecordDebug||Boolean||True/False||Toggles debug mode for the module for increased logging.|
|/Root/Server||onrecordThreadPoolSize||Number||Default: 10||The number of threads used to send data. (Optional).|
|/Root/Server||onrecordThreadPoolTerminationTimeout||Number||Default: 5 (seconds)||When shutting down, time, in seconds, to wait to allow all requests to be sent (Optional).|
|/Root/Server||onrecordThreadIdleTimeout||Number||Default: 60 (seconds)||If the pool currently has more than ThreadPoolSize threads, excess threads will be terminated if they have been idle for more than the ThreadIdleTimeout (Optional).|
The module allows you to run a bash script (linux) or a batch file (windows) when a stream recording completes in the ontext of a wowza application. This gives you the flexibility to trigger another script or program directly using shell programming instead of handling the complexity in wowza’s module with java.
|RECORD_COMPLETE||Applicable when actual file writing (recording) on disk completes. (most useful)|
For each event, the module will automatically pass in valuable and relevant arguments to the script. It is then the developer’s work to capture the arguments in the script and do the needful with them. Arguments are positional and thus the order is important. Given below is a table of how many arguments to expect and what they imply.
|RECORD_COMPLETE||PARAM #1 => event name|
PARAM #2 => stream name
PARAM #3 => Record media file path
NOTE: Ensure your script has sufficient execution permissions as per the operating system requirements.