For Ad Manager integration, you need to create a live configuration for a given livestream event. The Video Stitcher API registers this config with Ad Manager.
Create a slate
Before you create the live configuration, you need to create a slate. The Video Stitcher API inserts a default slate video when ads can't be inserted. You must register slate video with the Video Stitcher API to indicate the slate to use in the absence of ads. The slate video can be any MP4 file with at least one audio track.
You have two options for creating this slate. You can create a default network slate in your Ad Manager account or you can create slates using the Video Stitcher API.
Create a slate in Ad Manager
To create a default network slate in your Ad Manager account, follow the steps at Create a slate to fill content gaps and then skip to section Create the live config.
Create a slate using the Video Stitcher API
To create a slate using the Video Stitcher API, use the
projects.locations.slates.create
method.
Before using any of the request data, make the following replacements:
: your Google Cloud project number; this is located in the Project number field on the IAM Settings pagePROJECT_NUMBER
: the location in which to create your slate; use one of the supported regionsLOCATION Show locationsus-central1
us-east1
us-west1
asia-east1
asia-south1
asia-southeast1
europe-west1
southamerica-east1
: a user-defined identifier for the slate. 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.SLATE_ID
: the public URI for an MP4 video with at least one audio track (sample video)SLATE_URL
: the numeric identifier for your Ad Manager network; you can find this in the Global settings for the publisher accountNETWORK_CODE
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "uri": "SLATE_URL ", "gamSlate": { "networkCode": "NETWORK_CODE " } } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /slates?slateId=SLATE_ID "
PowerShell (Windows)
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "uri": "SLATE_URL ", "gamSlate": { "networkCode": "NETWORK_CODE " } } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /slates?slateId=SLATE_ID " | Select-Object -Expand Content
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 /slates/SLATE_ID ", "verb": "create" }, "done": false }
This command creates a
long-running operation (LRO)
that you can query to track progress. Copy the returned
,
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 slate 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:
: your Google Cloud project number; this is located in the Project number field on the IAM Settings pagePROJECT_NUMBER
: the location of the data; use one of the supported regionsLOCATION Show locationsus-central1
us-east1
us-west1
asia-east1
asia-south1
asia-southeast1
europe-west1
southamerica-east1
: the identifier for the operationOPERATION_ID
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /operations/OPERATION_ID "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /operations/OPERATION_ID " | Select-Object -Expand Content
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 /slates/SLATE_ID ", "verb": "create" }, "done": true, "response": { "@type": "type.googleapis.com/google.cloud.video.stitcher.v1.Slate", "name": "projects/PROJECT_NUMBER /locations/LOCATION /slates/SLATE_ID ", "uri": "SLATE_URL ", "gamSlate": { "networkCode": "NETWORK_CODE " "gamSlateId": "GAM_SLATE_ID " } } }
Create the live config
To create the config, use the
projects.locations.liveConfigs.create
method. See the
live config reference documentation
for optional fields (like
custom headers).
Before using any of the request data, make the following replacements:
: your Google Cloud project number; this is located in the Project number field on the IAM Settings pagePROJECT_NUMBER
: the location in which to create your live config; use one of the supported regionsLOCATION Show locationsus-central1
us-east1
us-west1
asia-east1
asia-south1
asia-southeast1
europe-west1
southamerica-east1
: a user-defined identifier for the live 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.LIVE_CONFIG_ID
: the source URL to the livestream video manifest. This must be accessible to the Video Stitcher API. The URL must either be publicly accessible or, if URL signing is enabled for the CDN, a registered CDN key has been provided to the Video Stitcher API. If you created a test livestream using the Live Stream API, then this is the URI to theSOURCE_LIVESTREAM_URI main.m3u8
ormain.mpd
file in the Cloud Storage bucket. the URL for ad metadata retrieved from ad servers; for Ad Manager integration, this must be a valid Ad Manager live video ad tag. To get a valid ad tag, follow the steps on Generate video and audio ad tags with these modifications:AD_TAG_URI - For Live traffic, enable live traffic.
- For the Player SDK type, select Google IMA SDK.
- Add the parameter
ad_rule=0
to the tag (for example, add&ad_rule=0
to the end).
: the ID of the slate to use in the absence of stitched adsSLATE_ID
: the numeric identifier for your Ad Manager network; you can find this in the Global settings for the publisher account.NETWORK_CODE
: the ad tracking behavior for your stream. For IMA SDK integrations, useAD_TRACKING CLIENT
. For server-side ad tracking, useSERVER
. You may also override this value on a per-session basis later.
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
cat > request.json << 'EOF' { "sourceUri": "SOURCE_LIVESTREAM_URI ", "adTagUri": "AD_TAG_URI ", "defaultSlate": "projects/PROJECT_NUMBER /locations/LOCATION /slates/SLATE_ID ", "gamLiveConfig": { "networkCode": "NETWORK_CODE ", }, "adTracking": "AD_TRACKING " } EOF
Then execute the following command to send your REST request:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth application-default print-access-token)" \
-H "x-goog-user-project:PROJECT_NUMBER " \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /liveConfigs?liveConfigId=LIVE_CONFIG_ID "
PowerShell (Windows)
Save the request body in a file named request.json
.
Run the following command in the terminal to create or overwrite
this file in the current directory:
@' { "sourceUri": "SOURCE_LIVESTREAM_URI ", "adTagUri": "AD_TAG_URI ", "defaultSlate": "projects/PROJECT_NUMBER /locations/LOCATION /slates/SLATE_ID ", "gamLiveConfig": { "networkCode": "NETWORK_CODE ", }, "adTracking": "AD_TRACKING " } '@ | Out-File -FilePath request.json -Encoding utf8
Then execute the following command to send your REST request:
$cred = gcloud auth application-default print-access-token
$headers = @{ "Authorization" = "Bearer $cred"; "x-goog-user-project" = "PROJECT_NUMBER " }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /liveConfigs?liveConfigId=LIVE_CONFIG_ID " | Select-Object -Expand Content
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 /liveConfigs/LIVE_CONFIG_ID ", "verb": "create" }, "done": false }
The Video Stitcher API asynchronously registers the config on your Ad Manager account. This may take a couple of minutes.
This command creates a long-running operation (LRO) that you can query to track progress. For more information, see Check for the result.
Get the config
To get the config, use the
projects.locations.liveConfigs.get
method.
Before using any of the request data, make the following replacements:
: your Google Cloud project number; this is located in the Project number field on the IAM Settings pagePROJECT_NUMBER
: the location of the live config; use one of the supported regionsLOCATION Show locationsus-central1
us-east1
us-west1
asia-east1
asia-south1
asia-southeast1
europe-west1
southamerica-east1
: the user-defined identifier for the live configLIVE_CONFIG_ID
To send your request, expand one of these options:
curl (Linux, macOS, or Cloud Shell)
Execute the following command:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /liveConfigs/LIVE_CONFIG_ID "
PowerShell (Windows)
Execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method GET `
-Headers $headers `
-Uri "https://videostitcher.googleapis.com/v1/projects/PROJECT_NUMBER /locations/LOCATION /liveConfigs/LIVE_CONFIG_ID " | Select-Object -Expand Content
You should receive a JSON response similar to the following:
{ "name": "projects/PROJECT_NUMBER /locations/LOCATION /liveConfigs/LIVE_CONFIG_ID ", "sourceUri": "SOURCE_LIVESTREAM_URI ", "adTagUri": "AD_TAG_URI ", "gamLiveConfig": { "networkCode": "NETWORK_CODE ", "assetKey": "ASSET_KEY ", "customAssetKey": "PROJECT_NUMBER -LOCATION -LIVE_CONFIG_ID " }, "state": "READY", "adTracking": "CLIENT", "defaultSlate": "projects/PROJECT_NUMBER /locations/LOCATION /slates/SLATE_ID ", "stitchingPolicy": "CUT_CURRENT" }
Find the customAssetKey
field and copy the returned