Execute custom logic via shell script after recording a stream with Wowza streaming engine

"Only a life lived for others is a life worthwhile." – Albert Einstein

Execute custom logic via shell script after recording a stream with Wowza streaming engine

INTRODUCTION


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.

Contents


Prerequisites


Wowza Streaming Engine 4.8.x or later is required.

Installation


  1. Download the latest release of rtmpworld-wse-plugin-onrecord  & rtmpworld-wse-utilities shared library builds/archives.
  2. Extract the contents from the downloaded (zipped) packages.
  3. 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
  4. 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).
  5. 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).

Configuration


To enable this module, add the following module definition to your application configuration. See Configure modules for details.

NAMEDESCRIPTIONFULLY QUALIFIED CLASS NAME
ModuleOnRecordScript
Enables you to trigger a shell script/batch file on record completion
com.rtmpworld.server.wowza.plugins.ModuleOnRecordScript

Properties


After enabling the module, you can adjust the default settings by adding the following properties to your application. See Configure properties for details.

PATHNAMETYPEVALUENOTES
/Root/ApplicationonrecordScriptWorkingDir
StringD:/wowzascriptsThe absolute path of the working directory.

/Root/Application
onrecordRecordCompleteScript
String
D:/wowzascripts/record_complete.batThe absolute path of the script to be executed on record complete event (when file write finishes).


/Root/Application
onrecordDebug
BooleanTrue/FalseToggles debug mode for the module for increased logging.
/Root/ServeronrecordThreadPoolSizeNumberDefault: 10The number of threads used to send data. (Optional).
/Root/ServeronrecordThreadPoolTerminationTimeoutNumberDefault: 5 (seconds)When shutting down, time, in seconds, to wait to allow all requests to be sent (Optional).
/Root/ServeronrecordThreadIdleTimeoutNumberDefault: 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).

Use Wowza Engine Manager interface to add & configure modules for your Wowza Streaming Engine instance.

Usage


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.

For Developers


EVENT NAMEDESCRIPTION
RECORD_COMPLETEApplicable when actual file writing (recording) on disk completes. (most useful)

CAPTURING ARGUMENTS

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.

EVENTARGUMENTS
RECORD_COMPLETEPARAM #1 => event name
PARAM #2 => stream name
PARAM #3 => Record media file path

In bash you can capture positional arguments as : $1, $2 etc whereas in windows batch file you can capture arguments as %1, %2 etc.

NOTE: Ensure your script has sufficient execution permissions as per the operating system requirements.

Known Issues


NA