# Configure the Media Analysis Task

You can run media analysis on documents by using the `MediaServerAnalysis` import task. This task only processes documents that have the document field `AUTN_NEEDS_MEDIA_SERVER_ANALYSIS`, so you must add this field to any document that you want to process.

To configure the Media Server Analysis task

1. Write a Lua script to add the document field `AUTN_NEEDS_MEDIA_SERVER_ANALYSIS` to the documents that you want to analyze. For an example script that adds a field to a document, see Add a Field to a Document.
2. Open the CFS configuration file.

3. In the `[ImportTasks]` section, configure a `Pre` or `Post` import task to run your Lua script. For example:

       [ImportTasks]
       Pre0=Lua:scripts/TagVideoFiles.lua

4. Add another `Pre` or `Post` task to run the `MediaServerAnalysis` task. Set the `Pre` or `Post` parameter to `MediaServerAnalysis`, followed by a colon (`:`), followed by the name of the section in the CFS configuration file that contains the task settings. For example:

       Pre1=MediaServerAnalysis:MediaServerSettings

5. Create a new section in the configuration file, using the name you specified in Step 4.

6. In the new section, set the following parameters:

   `MediaServerHost` | The host name and ACI port of your Media Server. To distribute requests between several servers, specify a comma-separated list of servers.
   `MediaAnalysisTransform` | (Optional) To transform the metadata produced by Media Server, before CFS adds the data to your documents, set this parameter to the path of the XSL transformation to use. By default, CFS adds the information to your documents in a document field named `MediaServerAnalysis`, in the same structure that is returned from Media Server.

7. Specify the Media Server configuration file that you want to use for running analysis:

   - If you saved your configuration file in the directory specified by the `ConfigDirectory` parameter, in the `[Paths]` section of the Media Server configuration file, set `MediaServerConfigurationName` to the name of the configuration.
   - If you saved your configuration file in a location accessible by CFS, set the parameter `MediaServerConfigurationFileName` to the path of the configuration file. If you set a relative path, specify the path relative to CFS, not relative to Media Server.

8. Specify how to send media to Media Server:

   - If your Media Server can read files directly from the CFS working directory, set `ReadFromOriginalLocation=TRUE`.
   - To copy files to a shared folder, set the configuration parameter `MediaServerSharedPath`. This folder must be accessible to both CFS and Media Server. CFS copies files to the shared folder so that Media Server can read them. Micro Focus recommends that you use a shared folder for sending large files.
   - To send files to Media Server using HTTP POST requests, set neither `ReadFromOriginalLocation` nor `MediaServerSharedPath`.
9. Save and close the configuration file.

## Examples

The following example shows how to configure the `MediaServerAnalysis` task. This example runs analysis using a configuration named `RecognizeFacesInVideo` that exists on the Media Server machine:

    [ImportTasks]
    Pre0=Lua:TagVideoFiles.lua
    Pre1=MediaServerAnalysis:MediaServerSettings

    [MediaServerSettings]
    MediaServerHost=localhost:14000
    MediaServerConfigurationName=RecognizeFacesInVideo
    ReadFromOriginalLocation=TRUE

The following example is similar but configures CFS to send a configuration file to Media Server:

    [ImportTasks]
    Pre0=Lua:TagVideoFiles.lua
    Pre1=MediaServerAnalysis:MediaServerSettings

    [MediaServerSettings]
    MediaServerHost=localhost:14000
    MediaServerConfigurationFileName=./script_resources/mediaserver/facerecognition.cfg
    ReadFromOriginalLocation=TRUE

If your CFS and Media Server are running on separate machines, you can configure CFS to copy media files to a shared folder:

    [ImportTasks]
    Pre0=Lua:TagVideoFiles.lua
    Pre1=MediaServerAnalysis:MediaServerSettings

    [MediaServerSettings]
    MediaServerHost=media1:14000,media2:14000
    MediaServerConfigurationName=RecognizeFacesInVideo
    MediaServerSharedPath=\\server\videofiles

CFS adds the results of analysis to your documents. By default, the information is added in the same structure that is returned from Media Server, in a document field named `MediaServerAnalysis`. Using the configuration parameter `MediaAnalysisTransform`, you can configure CFS to run an XSL transformation to transform the information before adding it a document:

    [ImportTasks]
    Pre0=Lua:TagVideoFiles.lua
    Pre1=MediaServerAnalysis:MediaServerSettings

    [MediaServerSettings]
    MediaServerHost=media1:14000,media2:14000
    MediaServerConfigurationName=RecognizeFacesInVideo
    MediaServerSharedPath=\\server\videofiles
    MediaAnalysisTransform=./xslt/transform.xsl

For more information about the parameters that you can use to configure this task, refer to the Connector Framework Server Reference.

_FT_HTML5_bannerTitle.htm