# Method: videos.annotate

- [HTTP request](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#body.HTTP_TEMPLATE)
- [Request body](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#body.request_body)
  - [JSON representation](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#body.request_body.SCHEMA_REPRESENTATION)
- [Response body](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#body.response_body)
- [Authorization Scopes](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#body.aspect)
- [Feature](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#Feature)
- [VideoContext](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#VideoContext)
  - [JSON representation](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#VideoContext.SCHEMA_REPRESENTATION)
- [LabelDetectionConfig](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#LabelDetectionConfig)
  - [JSON representation](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#LabelDetectionConfig.SCHEMA_REPRESENTATION)
- [LabelDetectionMode](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#LabelDetectionMode)
- [ShotChangeDetectionConfig](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ShotChangeDetectionConfig)
  - [JSON representation](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ShotChangeDetectionConfig.SCHEMA_REPRESENTATION)
- [ExplicitContentDetectionConfig](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ExplicitContentDetectionConfig)
  - [JSON representation](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ExplicitContentDetectionConfig.SCHEMA_REPRESENTATION)
- [SpeechTranscriptionConfig](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechTranscriptionConfig)
  - [JSON representation](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechTranscriptionConfig.SCHEMA_REPRESENTATION)
- [SpeechContext](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechContext)
  - [JSON representation](https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechContext.SCHEMA_REPRESENTATION)

Performs asynchronous video annotation. Progress and results can be retrieved through the `google.longrunning.Operations` interface. `Operation.metadata` contains `AnnotateVideoProgress` (progress). `Operation.response` contains `AnnotateVideoResponse` (results).

### HTTP request

`POST https://videointelligence.googleapis.com/v1beta2/videos:annotate`

The URL uses [Google API HTTP annotation](https://github.com/googleapis/googleapis/blob/master/google/api/http.proto) syntax.

### Request body

The request body contains data with the following structure:

| JSON representation ||
|---|---|
| ``` { "inputUri": string, "inputContent": string, "features": [ enum(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#Feature`) ], "videoContext": { object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#VideoContext`) }, "outputUri": string, "locationId": string } ``` |

| Fields ||
|---|---|
| `inputUri` | `string` Input video location. Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) URIs are supported, which must be specified in the following format: `gs://bucket-id/object-id` (other URI formats return `https://docs.cloud.google.com/video-intelligence/docs/reference/rest/Shared.Types/Code#ENUM_VALUES.INVALID_ARGUMENT`). For more information, see [Request URIs](https://docs.cloud.google.com/storage/docs/reference-uris). A video URI may include wildcards in `object-id`, and thus identify multiple videos. Supported wildcards: '\*' to match 0 or more characters; '?' to match 1 character. If unset, the input video should be embedded in the request as `inputContent`. If set, `inputContent` should be unset. |
| `inputContent` | `string (https://developers.google.com/discovery/v1/type-format format)` The video data bytes. If unset, the input video(s) should be specified via `inputUri`. If set, `inputUri` should be unset. A base64-encoded string. <br /> |
| `features[]` | ``enum(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#Feature`)`` Requested video annotation features. |
| `videoContext` | ``object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#VideoContext`)`` Additional video context and/or feature-specific parameters. |
| `outputUri` | `string` Optional location where the output (in JSON format) should be stored. Currently, only [Google Cloud Storage](https://cloud.google.com/storage/) URIs are supported, which must be specified in the following format: `gs://bucket-id/object-id` (other URI formats return `https://docs.cloud.google.com/video-intelligence/docs/reference/rest/Shared.Types/Code#ENUM_VALUES.INVALID_ARGUMENT`). For more information, see [Request URIs](https://docs.cloud.google.com/storage/docs/reference-uris). |
| `locationId` | `string` Optional cloud region where annotation should take place. Supported cloud regions: `us-east1`, `us-west1`, `europe-west1`, `asia-east1`. If no region is specified, a region will be determined based on video file location. |

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/video-intelligence/docs/reference/rest/Shared.Types/Operation`.

### Authorization Scopes

Requires the following OAuth scope:

- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Auth Guide](https://cloud.google.com/docs/authentication/).

## Feature

Video annotation feature.

| Enums ||
|---|---|
| `FEATURE_UNSPECIFIED` | Unspecified. |
| `LABEL_DETECTION` | Label detection. Detect objects, such as dog or flower. |
| `SHOT_CHANGE_DETECTION` | Shot change detection. |
| `EXPLICIT_CONTENT_DETECTION` | Explicit content detection. |
| `SPEECH_TRANSCRIPTION` | Speech transcription. |

## VideoContext

Video context and/or feature-specific parameters.

| JSON representation ||
|---|---|
| ``` { "segments": [ { object(`VideoSegment`) } ], "labelDetectionConfig": { object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#LabelDetectionConfig`) }, "shotChangeDetectionConfig": { object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ShotChangeDetectionConfig`) }, "explicitContentDetectionConfig": { object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ExplicitContentDetectionConfig`) }, "speechTranscriptionConfig": { object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechTranscriptionConfig`) } } ``` |

| Fields ||
|---|---|
| `segments[]` | ``object(`VideoSegment`)`` Video segments to annotate. The segments may overlap and are not required to be contiguous or span the whole video. If unspecified, each video is treated as a single segment. |
| `labelDetectionConfig` | ``object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#LabelDetectionConfig`)`` Config for LABEL_DETECTION. |
| `shotChangeDetectionConfig` | ``object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ShotChangeDetectionConfig`)`` Config for SHOT_CHANGE_DETECTION. |
| `explicitContentDetectionConfig` | ``object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#ExplicitContentDetectionConfig`)`` Config for EXPLICIT_CONTENT_DETECTION. |
| `speechTranscriptionConfig` | ``object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechTranscriptionConfig`)`` Config for SPEECH_TRANSCRIPTION. |

## LabelDetectionConfig

Config for LABEL_DETECTION.

| JSON representation ||
|---|---|
| ``` { "labelDetectionMode": enum(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#LabelDetectionMode`), "stationaryCamera": boolean, "model": string } ``` |

| Fields ||
|---|---|
| `labelDetectionMode` | ``enum(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#LabelDetectionMode`)`` What labels should be detected with LABEL_DETECTION, in addition to video-level labels or segment-level labels. If unspecified, defaults to `SHOT_MODE`. |
| `stationaryCamera` | `boolean` Whether the video has been shot from a stationary (i.e. non-moving) camera. When set to true, might improve detection accuracy for moving objects. Should be used with `SHOT_AND_FRAME_MODE` enabled. |
| `model` | `string` Model to use for label detection. Supported values: "builtin/stable" (the default if unset) and "builtin/latest". |

## LabelDetectionMode

Label detection mode.

| Enums ||
|---|---|
| `LABEL_DETECTION_MODE_UNSPECIFIED` | Unspecified. |
| `SHOT_MODE` | Detect shot-level labels. |
| `FRAME_MODE` | Detect frame-level labels. |
| `SHOT_AND_FRAME_MODE` | Detect both shot-level and frame-level labels. |

## ShotChangeDetectionConfig

Config for SHOT_CHANGE_DETECTION.

| JSON representation ||
|---|---|
| ``` { "model": string } ``` |

| Fields ||
|---|---|
| `model` | `string` Model to use for shot change detection. Supported values: "builtin/stable" (the default if unset) and "builtin/latest". |

## ExplicitContentDetectionConfig

Config for EXPLICIT_CONTENT_DETECTION.

| JSON representation ||
|---|---|
| ``` { "model": string } ``` |

| Fields ||
|---|---|
| `model` | `string` Model to use for explicit content detection. Supported values: "builtin/stable" (the default if unset) and "builtin/latest". |

## SpeechTranscriptionConfig

Config for SPEECH_TRANSCRIPTION.

| JSON representation ||
|---|---|
| ``` { "languageCode": string, "maxAlternatives": number, "filterProfanity": boolean, "speechContexts": [ { object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechContext`) } ], "audioTracks": [ number ] } ``` |

| Fields ||
|---|---|
| `languageCode` | `string` *Required* The language of the supplied audio as a [BCP-47](https://www.rfc-editor.org/rfc/bcp/bcp47.txt) language tag. Example: "en-US". See [Language Support](https://cloud.google.com/speech/docs/languages) for a list of the currently supported language codes. |
| `maxAlternatives` | `number` *Optional* Maximum number of recognition hypotheses to be returned. Specifically, the maximum number of `SpeechRecognitionAlternative` messages within each `SpeechRecognitionResult`. The server may return fewer than `maxAlternatives`. Valid values are `0`-`30`. A value of `0` or `1` will return a maximum of one. If omitted, will return a maximum of one. |
| `filterProfanity` | `boolean` *Optional* If set to `true`, the server will attempt to filter out profanities, replacing all but the initial character in each filtered word with asterisks, e.g. "f\*\*\*". If set to `false` or omitted, profanities won't be filtered out. |
| `speechContexts[]` | ``object(`https://docs.cloud.google.com/video-intelligence/docs/reference/rest/v1beta2/videos/annotate#SpeechContext`)`` *Optional* A means to provide context to assist the speech recognition. |
| `audioTracks[]` | `number` *Optional* For file formats, such as MXF or MKV, supporting multiple audio tracks, specify up to two tracks. Default: track 0. |

## SpeechContext

Provides "hints" to the speech recognizer to favor specific words and phrases in the results.

| JSON representation ||
|---|---|
| ``` { "phrases": [ string ] } ``` |

| Fields ||
|---|---|
| `phrases[]` | `string` *Optional* A list of strings containing words and phrases "hints" so that the speech recognition is more likely to recognize them. This can be used to improve the accuracy for specific words and phrases, for example, if specific commands are typically spoken by the user. This can also be used to add additional words to the vocabulary of the recognizer. See [usage limits](https://cloud.google.com/speech/limits#content). |