Using the Video Stitcher API, you create a live session each time you start playback of a live stream in which ads served by Google Ad Manager are dynamically stitched during ad breaks. The response specifies the playback URL and the configuration of the live session.
This document describes how to create and manage a live session. For more details, see the REST documentation.
Before you begin
- Create a live config. For the integration with
Google Ad Manager, ensure that the
gamLiveConfig
object is set. - If you are specifying a slate, ensure that the
gamSlate
object is set on the slate you register.
Create a live session
To create a live session using the API directly, use the
projects.locations.liveSessions.create
method.
The liveConfig
field is the only required field in the JSON body. You can set
or override the following optional parameters per live session (as shown in
the following REST example):
manifestOptions
: specifies which video renditions are generated in the stitched video manifest and the ordering of the renditions; see the manifest options documentationadTracking
: select either client-side ad tracking or server-side ad tracking; this overrides the value in the live config for the sessiontargetingParameters
: a Google Ad Manager ad tag can contain targeting parameters that can be updated per session; provide a mapping in this field (for example, to replace the[my_key]
macro with the stringmy_value
, see the REST example)
REST
Before using any of the request data, make the following replacements:
PROJECT_NUMBER
: your Google Cloud project number located in the Project number field on the IAM Settings pageLOCATION
: the location in which to create your session; use one of the supported regionsShow locationsus-central1
us-east1
us-west1
asia-east1
asia-south1
asia-southeast1
europe-west1
southamerica-east1
LIVE_CONFIG_ID
: the user-defined identifier for the live config
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/liveSessions/SESSION_ID", "playUri": "PLAY_URI", "manifestOptions": { "includeRenditions": [ { "bitrateBps": 150000, "codecs": "hvc1.1.4.L126.B0" }, { "bitrateBps": 440000, "codecs": "hvc1.1.4.L126.B0" } ], "bitrateOrder": "DESCENDING" }, "gamSettings": { "streamId": "STREAM_ID" }, "liveConfig": "projects/PROJECT_NUMBER/locations/LOCATION/liveConfigs/LIVE_CONFIG_ID", "adTracking": "SERVER" }
C#
Before trying this sample, follow the C# setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API C# API reference documentation.
To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Go
Before trying this sample, follow the Go setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Go API reference documentation.
To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Java
Before trying this sample, follow the Java setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Java API reference documentation.
To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Node.js
Before trying this sample, follow the Node.js setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Node.js API reference documentation.
To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
PHP
Before trying this sample, follow the PHP setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API PHP API reference documentation.
To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Python
Before trying this sample, follow the Python setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Python API reference documentation.
To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
Ruby
Before trying this sample, follow the Ruby setup instructions in the Video Stitcher API quickstart using client libraries. For more information, see the Video Stitcher API Ruby API reference documentation.
To authenticate to Video Stitcher API, set up Application Default Credentials. For more information, see Set up authentication for a local development environment.
The Video Stitcher API generates a unique session ID for each request. A
session expires if the playUri
is not requested within the past 5 minutes.
You can use the returned STREAM_ID
to
inspect the live session.
Inspect live sessions enabled by Google Ad Manager
To see ad tag details for sessions, use the
Stream activity monitor in Ad Manager to
see details about ad requests. You can use the STREAM_ID
to debug the stream session. To find the STREAM_ID
for
a live session, see Get a session.