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
Create a new configuration to send to Media Server with the process
action, or open an existing configuration that you want to modify.
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
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
OverlayInput
to specify the name of the output track from the overlay transformation task. In this example the track is named Overlay.Output
.Save and close the configuration file. Micro Focus recommends that you save your configuration files in the location specified by the ConfigDirectory
parameter.
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.
|