Create a configuration for a VOD session

For Ad Manager integration, you need to create an ad tag for the VOD session. You also need to create a VOD configuration. The Video Stitcher API registers this config with Ad Manager.

Create an ad tag in Ad Manager

Perform the following steps in your Ad Manager account:

  1. Add a new ad unit.
  2. Activate ad rules.
  3. Create a new ad rule. As part of this step, find the Targeting > Inventory section in Ad Manager. Select the new ad unit from the previous step.

  4. Create a valid ad tag by following the steps on Generate video and audio ad tags with the following modifications:

    • For the Player SDK type, select Google IMA SDK.
    • Add the parameter ad_rule=1 to the tag (for example, add &ad_rule=1 to the end).
    • Add the parameter vid_d=vod-asset-duration-in-secs to the tag (for example, add &vid_d=1800 to the end for a 30 minute VOD asset).
    • Modify the parameter output=vast to be output=xml_vmap1. The Video Multiple Ad Playlist (VMAP) specification is the only supported output type.

Create a VOD config

To create the config, use the projects.locations.vodConfigs.create method. See the VOD config reference documentation for optional fields (like custom headers).

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location in which to create your VOD config; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • VOD_CONFIG_ID: a user-defined identifier for the VOD config. This ID can only contain lower-case letters, numbers, and hyphens. The first character must be a letter, the last character must be a letter or a number, and the entire ID has a 63 character maximum.
  • VOD_URI: the URI of the media to stitch. This URI must reference either an MPEG-DASH manifest (MPD) file or an HLS manifest (M3U8) file. Use a public URI or an unsigned URI for which you registered a CDN key.
  • AD_TAG_URI
    the URL for ad metadata retrieved from ad servers; for Ad Manager integration, this must be a valid Ad Manager video ad tag. To get a valid ad tag, follow the steps in the previous section Create an ad tag in Ad Manager.
  • NETWORK_CODE: the numeric identifier for your Ad Manager network; you can find this in the Global settings for the publisher account

Request JSON body:

{
  "sourceUri": "VOD_URI",
  "adTagUri": "AD_TAG_URI",
  "gamVodConfig": {
    "networkCode": "NETWORK_CODE"
  }
}

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/vodConfigs/VOD_CONFIG_ID",
    "verb": "create",
    "cancelRequested": false,
    "apiVersion": "v1"
  },
  "done": false
}

This command creates a long-running operation (LRO) that you can query to track progress. Copy the returned OPERATION_ID, which is the last part of the name field, to use in the next section.

Check for the result

Use the projects.locations.operations.get method to check if the VOD config has been created. If the response contains "done: false", repeat the command until the response contains "done: true".

Before using any of the request data, make the following replacements:

  • PROJECT_NUMBER: your Google Cloud project number; this is located in the Project number field on the IAM Settings page
  • LOCATION: the location of the data; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-west1
    • asia-east1
    • asia-south1
    • asia-southeast1
    • europe-west1
    • southamerica-east1
  • OPERATION_ID: the identifier for the operation

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/operations/OPERATION_ID",
  "metadata": {
    "@type": "type.googleapis.com/google.cloud.common.OperationMetadata",
    "createTime": CREATE_TIME,
    "endTime": END_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/vodConfigs/VOD_CONFIG_ID",
    "verb": "create"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.video.stitcher.v1.VodConfig",
    "name": "projects/PROJECT_NUMBER/locations/LOCATION/vodConfigs/VOD_CONFIG_ID",
    "sourceUri": "VOD_URI",
    "adTagUri": "AD_TAG_URI",
    "gamVodConfig": {
      "networkCode": "NETWORK_CODE"
    },
    "state": "READY"
  }
}

Check that the state is set to READY. If not, wait for a few seconds and send the request again.

For more information on VOD configs, see Create and manage a VOD config.