Skip to main content
Version: 2.11

User defined Scripts

User defined scripts are run automatically by the Ant Media Server after the MP4 Muxing process (recording) finishes or VoD upload process finishes. It enables users to make some changes on the mp4 file. A few examples:

  1. Creating different resolutions for VoD serving ( Using adaptive bitrate on the fly will spend more resources, you can just transcode once for each VoD with your own user defined script after every muxing operations )

  2. Merging VoDs with ffmpeg

  3. Adding some watermark to VoDs after the stream is saved.

You can get creative with user-defined scripts, there are no limits. They are called after each streams recording process is finished or each VoD upload process is finished.

MP4 muxing(recording) finish process

 It will work after the MP4 Muxing(recording) process finishes. Let’s have a look at that step by step.

  1. Define run script location in App Settings
  2. Script running instructions

Define MP4 muxing run script location in App Settings

You can set up a custom post-processing script for MP4 recordings directly from the Advanced Settings in the Ant Media Web Panel. To do this:

  1. Log into the Ant Media Server Web Panel (http://YOUR_SERVER_IP:5080)
  2. Navigate to Applications, select your app (LiveApp, WebRTCAppEE, etc.), go to Advanced Settings
  3. Locate the MP4 muxerFinishScript field, and enter the script path (e.g., /path/to/scriptFile.sh).
  4. Finally, save the settings.

Usage:

  • For example, if the script is located at /usr/local/antmedia then setting would be as follows:

    "muxerFinishScript": "/usr/local/antmedia/scriptFile.sh",
  • The script should be able to executable permission

    Mark the file as executable with below code:

    chmod +x scriptFile.sh

Setting References: settings.muxerFinishScript Setting

MP4 Muxing script usage instructions

After the muxing process is finished, the AMS runs the following code snippets.

scriptFilePath fullPathOfMP4File

Example:

~/test_script.sh /usr/local/antmedia/webapps/LiveApp/streams/test_stream.mp4

When script is finished successfully, AMS writes in INFO log as a below:

running muxer finish script: ~/test_script.sh /usr/local/antmedia/webapps/LiveApp/streams/test_stream.mp4

VoD upload finish process

It will work after the VoD upload process finishes. Let’s have a look at that step by step.

  1. Define run script location in App Settings
  2. Script running instructions

Define VoD upload run script location in App Settings

You can configure a custom post-processing script for VOD uploads directly from the Advanced Settings in the Ant Media Web Panel. To do this:

  1. Log in to the Ant Media Server Web Panel (http://YOUR_SERVER_IP:5080)
  2. Navigate to Applications, select your app (LiveApp, WebRTCAppEE, etc.), go to Advanced Settings
  3. Locate the vodUploadFinishScript field, and enter the script path (e.g., /path/to/scriptFile.sh).
  4. Finally, save the settings.

Usage:

  • For example, if the script is located at /usr/local/antmedia then setting would be as follows:
"vodUploadFinishScript": "/usr/local/antmedia/scriptFile.sh",
  • The script should be able to executable permission

    Mark the file as executable with below code:

    chmod +x scriptFile.sh

Setting References: settings.vodUploadFinishScript Setting

VoD Upload script usage instructions

After the VoD upload process is finished, the AMS runs the following code snippets.

scriptFilePath fullPathOfMP4File

Example:

~/test_script.sh /usr/local/antmedia/webapps/LiveApp/streams/test_stream.mp4

When script finished successfully, AMS writes in INFO log as a below:

running muxer finish script: ~/test_script.sh /usr/local/antmedia/webapps/LiveApp/streams/test_stream.mp4