Create and manage DVR sessions

This page shows you how to create and manage Live Stream API digital video recorder (DVR) sessions. A DVR session is a sub-resource of a channel. You can use a DVR session to record a future live stream. For more information, see the separate guide Create a DVR session.

Set up your Google Cloud project and authentication

If you have not created a Google Cloud project and credentials, see Before you begin.

Prerequisites

You must create the following resources before creating a DVR session:

  1. Create an input endpoint

  2. Create a channel with a retention config and manifest key

Create a DVR session

To create a DVR session, use the projects.locations.channels.dvrSessions.create method.

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 where your channel is located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-south1
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-north1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: a user-defined identifier for the channel
  • DVR_SESSION_ID: a user-defined identifier for the DVR session
  • INTERVAL_START_TIME: the mark-in Unix epoch time in the original live stream manifest; uses a timestamp in RFC3339 UTC "Zulu" format (for example, 2014-10-02T15:01:23Z)
  • INTERVAL_END_TIME: the mark-out Unix epoch time in the original live stream manifest; uses a timestamp in RFC3339 UTC "Zulu" format (for example, 2014-10-02T15:01:23Z)

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.video.livestream.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/dvrSessions/DVR_SESSION_ID",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

This command creates a long-running operation (LRO) that you can use to track the progress of your request. See Manage long-running operations for more information.

Get DVR session details

To get the details of a DVR session, use the projects.locations.channels.dvrSessions.get method.

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 where your channel is located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-south1
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-north1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: a user-defined identifier for the channel
  • DVR_SESSION_ID: a user-defined identifier for the DVR session

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/channels/CHANNEL_ID/dvrSessions/DVR_SESSION_ID",
  "createTime": CREATE_TIME,
  "startTime": START_TIME,
  "updateTime": UPDATE_TIME,
  "state": "SUCCEEDED",
  "dvrManifests": [
    {
      "manifestKey": "manifest_hls",
      "outputUri": "gs://BUCKET_NAME/dvr/DVR_SESSION_ID/main.m3u8"
    }
  ],
  "dvrWindows": [
    {
      "timeInterval": {
        "startTime": "INTERVAL_START_TIME",
        "endTime": "INTERVAL_END_TIME"
      }
    }
  ]
}

DVR sessions and the generated manifests are removed when the first segment expires per the parent channel's retentionConfig. If you want the session to last beyond the configured retention window, create a channel clip instead.

Update a DVR session

To update a DVR session, use the projects.locations.channels.dvrSessions.patch method.

The following example updates the DVR time windows used by the DVR session. Not all fields can be updated; see the list of supported fields.

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 where your channel is located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-south1
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-north1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: a user-defined identifier for the channel
  • DVR_SESSION_ID: a user-defined identifier for the DVR session
  • INTERVAL_START_TIME: the mark-in Unix epoch time in the original live stream manifest; uses a timestamp in RFC3339 UTC "Zulu" format (for example, 2014-10-02T15:01:23Z)
  • INTERVAL_END_TIME: the mark-out Unix epoch time in the original live stream manifest; uses a timestamp in RFC3339 UTC "Zulu" format (for example, 2014-10-02T15:01:23Z)

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.video.livestream.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/dvrSessions/DVR_SESSION_ID",
    "verb": "update",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

This command creates a long-running operation (LRO) that you can use to track the progress of your request. See Manage long-running operations for more information.

Update requests are rejected if the DVR session state is LIVE and the update could overwrite the current DVR manifest. The only exception to this is when the update makes the DVR session shorter (for example, changing the end time to now or sometime in the past); in this case, the DVR session stops immediately and the DVR session goes into the COOLDOWN state. After the 60-second cool down period, the DVR manifest is overwritten to reflect the updated start and end times.

List DVR sessions

To list all of the DVR sessions you created for a channel, use the projects.locations.channels.dvrSessions.list method.

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 where your channel is located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-south1
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-north1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: a user-defined identifier for the channel

To send your request, expand one of these options:

You should receive a JSON response similar to the following:

{
  "dvrSessions": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/dvrSessions/DVR_SESSION_ID",
      "createTime": CREATE_TIME,
      "startTime": START_TIME,
      "updateTime": UPDATE_TIME,
      "state": "SCHEDULED",
      "dvrManifests":[
        {
          "manifestKey": "manifest_hls",
          "outputUri": "gs://BUCKET_NAME/dvr/DVR_SESSION_ID/main.m3u8"
        }
      ],
      "dvrWindows":[
        {
          "timeInterval": {
            "startTime": "INTERVAL_START_TIME",
            "endTime": "INTERVAL_END_TIME"
          }
        }
      ]
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/dvrSessions/my-other-DVR-session",
      "createTime": CREATE_TIME,
      "startTime": START_TIME,
      "updateTime": UPDATE_TIME,
      "state": "SCHEDULED",
      "dvrManifests":[
        {
          "manifestKey": "manifest_hls2",
          "outputUri": "gs://BUCKET_NAME/dvr/my-other-DVR-session/main.m3u8"
        }
      ],
      "dvrWindows":[
        {
          "timeInterval": {
            "startTime": "INTERVAL_START_TIME",
            "endTime": "INTERVAL_END_TIME"
          }
        }
      ]
    },
  ]
}

Delete a DVR session

To delete a DVR session, use the projects.locations.channels.dvrSessions.delete method. This method deletes the DVR session task and the generated manifest. The resources created in the Cloud Storage bucket are deleted according to the retention config.

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 where your channel is located; use one of the supported regions
    Show locations
    • us-central1
    • us-east1
    • us-east4
    • us-west1
    • us-west2
    • northamerica-northeast1
    • southamerica-east1
    • asia-east1
    • asia-east2
    • asia-south1
    • asia-northeast1
    • asia-southeast1
    • australia-southeast1
    • europe-north1
    • europe-west1
    • europe-west2
    • europe-west3
    • europe-west4
  • CHANNEL_ID: a user-defined identifier for the channel
  • DVR_SESSION_ID: a user-defined identifier for the DVR session

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.video.livestream.v1.OperationMetadata",
    "createTime": CREATE_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/dvrSessions/DVR_SESSION_ID",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

This command creates a long-running operation (LRO) that you can use to track the progress of your request. See Manage long-running operations for more information.