Media Server 12.11

# Create an Overlay with a Lua Script

The `Overlay` transformation task creates an overlay for a video. This section demonstrates how to draw a custom overlay using a Lua script.

The Lua script that you write must define a function with the name `draw`. The function is passed each record from the input track. For example, the following function draws an ellipse using each record from the `Result` track produced by face detection:

    function draw(record)
       drawEllipse(record.FaceResult.face.ellipse, 3, rgb(255,255,255))
    end

For information about the Lua functions that you can use to draw an overlay, refer to the Media Server Reference.

To create an overlay with a Lua script

1. Create a new configuration to send to Media Server with the `process` action, or open an existing configuration that you want to modify.

2. In the `[Session]` section, add a new task by setting the `EngineN` parameter. You can give the task any name, for example:

       [Session]
       Engine0=Ingest
       ...
       Engine3=Overlay

3. Create a new configuration section to contain the task settings and set the following parameters:

   `Type` | The transformation engine to use. Set this parameter to `Overlay`.
   `Input` | The name of the track that contains the metadata to use to draw the overlay. This track does not need to include the video frames.
   `LuaScript` | The path of a Lua script to run to draw the overlay.

   For example:

       [Overlay]
       Type=Overlay
       Input=FaceDemographics.Result
       LuaScript=./configurations/overlayDemographics.lua

4. When you define your encoding task, use the parameter `OverlayInput` to specify the name of the output track from the overlay transformation task. In this example the track is named `Overlay.Output`.

5. Save and close the configuration file. Micro Focus recommends that you save your configuration files in the location specified by the `ConfigDirectory` parameter.

Example configuration to create an overlay using a Lua script

An example configuration file, `configurations/examples/Other/Overlay_Faces.cfg`, is included in your Media Server installation. This example ingests a video file or stream, performs face detection and demographics analysis, and encodes video with an overlay. The overlay is drawn by a Lua script that uses metadata from the demographics task to outline male faces in orange and female faces in purple.

© Copyright 2022 Micro Focus or one of its affiliates
Version 12.11 | Last updated February 2022

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to swpdl.idoldocsfeedback@microfocus.com.

We appreciate your feedback!

Product: IDOL Media Server 12.11

Topic Title: Create an Overlay with a Lua Script