# Train Video Matching

You must train Media Server by providing the video clips that you want to recognize. Each clip you provide is added to a database.

## Create a Database to Contain Video Clips

To create a database to contain known video clips, use the following procedure.

To create a database to contain video clips

- Use the action `CreateVideoMatchDatabase`. For example, to create a database named "movies":

      curl http://localhost:14000 -F action=CreateVideoMatchDatabase
                                  -F database=movies

## Add a Clip to the Database

After creating a database, train Media Server to recognize each video clip by running the action `TrainVideoMatchClip`.

To add a video clip to the database

- Add a clip using the action `TrainVideoMatchClip`. Set the following parameters:

  `database` | The name of the database to add the clip to. The database must already exist.
  `identifier` | (Optional) A unique identifier for the clip (maximum 254 bytes). If you do not set this parameter, Media Server generates an identifier automatically.
  `videodata` | (Set this or `videopath`, but not both). The video data. Files must be uploaded as multipart/form-data. For more information about sending data to Media Server, see Send Data by Using a POST Method.
  `videopath` | (Set this or `videodata`, but not both). The path of the file that contains the video clip. The path must be absolute, or relative to the Media Server executable file.
  `trainingoptions` | (Optional) A comma-separated list of training options to apply to the clip. Separate training options from their values using a colon (`:`). You can set the training option `maximumduration` to limit the amount of video used for training. For example, if you set `maximumduration:30s` then Media Server uses only the first 30 seconds of the video. This is usually sufficient for Media Server to identify a match. You cannot specify a value smaller than `10s`.

  For example:

      curl http://localhost:14000 -F action=TrainVideoMatchClip
                                  -F database=movies
                                  -F videodata=@clip.mp4
                                  -F trainingoptions=maximumduration:45s

  Alternatively, the following example provides the path of the clip rather than sending the data:

      curl http://localhost:14000 -F action=TrainVideoMatchClip
                                  -F database=movies
                                  -F videopath=clip.mp4
                                  -F trainingoptions=maximumduration:45s

  Media Server adds the clip to the database.

## List the Clips in a Database

To list the video clips that you have added to a database, use the following procedure.

To list the clips in a database

1. (Optional) First list the databases that have been created for video matching.

       http://localhost:14000/action=ListVideoMatchDatabases

   Media Server returns a list of databases.

2. List the clips that exist in one of the databases.

       http://localhost:14000/action=ListVideoMatchClips&database=movies

   Media Server returns a list of clips in the specified database.

## Manage Video Clips and Databases

To remove a video clip from a database, use the action `RemoveVideoMatchClip`.

To update or remove databases, use the following actions:

- To rename a video match database, use the action `RenameVideoMatchDatabase`.
- To delete a video match database and all of the information that it contains, use the action `RemoveVideoMatchDatabase`.

For more information about the actions that you can use to train Media Server, refer to the Media Server Reference.

_FT_HTML5_bannerTitle.htm