# Identify and Combine Time-Related Events

The Combine ESP engine combines records from two or more tracks. The engine produces an output track that contains exactly one record for every record in the first (`Input0`) input track. Each of the output records contains all related records from the other input track(s). The records from the first input track are output even if there are no related events in the other track(s).

One use case for this engine is combining records from analysis engines before running a transformation task. For example, face detection produces a record for each detected face. To blur several faces that appear simultaneously, you could combine the relevant records from face detection with the each ingested image before running the blur transformation task.

To identify and combine time-related events in two tracks

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
       ...
       Engine5=Combine

3. Create a new configuration section for the task, and set the following parameters:

   `Type` | The ESP engine to use. Set this parameter to `combine`.
   `Input0` | The first input track.
   `InputN` | The other input tracks (`Input1`, `Input2`, and so on). You must specify at least `Input1`.
   `TimestampCondition` | (Optional) Specifies time limits for matching records, based on the record timestamps. If you are processing images or documents, this parameter is ignored and records are considered related if they are associated with the same page.

   For more details about these parameters, including the values that they accept, refer to the Media Server Reference.

4. (Optional) To add custom logic that discards pairs of records unless they meet additional conditions, set the `LuaScript` parameter so that Media Server runs a Lua script to filter the results. For information about writing the script, see Write a Lua Script for an ESP Engine.

   `LuaScript` | The path and file name of a Lua script to run.

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

The following example runs face detection on an image file and blurs all of the faces that appear in the image. The combine task is used to combine the regions identified by face detection with the original image record produced by the ingest engine.

    [Session]
    Engine0=Ingest
    Engine1=FaceDetect
    Engine2=Combine
    Engine3=Blur
    Engine4=ToDisk

    [Ingest]
    Type=image

    [FaceDetect]
    Type=FaceDetect
    FaceDirection=any
    Orientation=any

    [Combine]
    Type=combine
    Input0=Image_1
    Input1=FaceDetect.Result

    [Blur]
    Type=Blur
    Input=Combine.Output

    [ToDisk]
    Type=ImageEncoder
    ImageInput=Blur.Output
    OutputPath=./_outputEncode/%token%.jpg

_FT_HTML5_bannerTitle.htm