建立及管理管道短片

本頁面說明如何建立及管理 Live Stream API 頻道短片。頻道短片是頻道的子資源。你可以使用頻道短片,從直播中建立隨選影片 (VOD) 檔案。這些 VOD 檔案會儲存至 Cloud Storage。詳情請參閱「從直播活動建立 VOD 短片」一文。

設定 Google Cloud 專案和驗證

如果您尚未建立 Google Cloud 專案和憑證,請參閱「開始前」一節。

事前準備

你必須先建立下列資源,才能建立頻道短片:

  1. 建立輸入端點

  2. 使用保留設定建立管道

建立頻道短片

請務必啟動頻道並開始將內容串流至頻道,然後再建立頻道短片。

如要建立頻道剪輯片段,請使用 projects.locations.channels.clips.create 方法。

使用任何要求資料之前,請先替換以下項目:

  • PROJECT_NUMBER:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位
  • LOCATION:頻道所在位置;請使用支援的區域之一
    顯示地區
    • 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:管道的使用者定義 ID
  • CLIP_ID:隨選影片短片的使用者定義 ID
  • MARK_IN_TIME:原始直播資訊清單中的 Unix Epoch 紀元時間;使用 RFC3339 世界標準時間「Zulu」格式的時間戳記 (例如 2014-10-02T15:01:23Z)
  • MARK_OUT_TIME:原始直播資訊清單中的 Mark-out Unix Epoch 時間;使用 RFC3339 世界標準時間「Zulu」格式的時間戳記 (例如 2014-10-02T15:01:23Z)
  • BUCKET_NAME:您建立用於儲存 VOD 短片資訊清單和片段檔案的 Cloud Storage 值區名稱;您可以使用建立直播資訊清單時建立的值區,也可以使用其他值區;您也可以在值區名稱後方加上目錄名稱 (例如 my-bucket/vod-clip)

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

{
  "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/clips/CLIP_ID",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

這個指令會建立長期執行作業 (LRO),您可以使用該作業追蹤要求的進度。詳情請參閱「管理長時間執行的作業 」。

取得管道短片詳細資料

如要取得頻道短片的詳細資料,請使用 projects.locations.channels.clips.get 方法。

使用任何要求資料之前,請先替換以下項目:

  • PROJECT_NUMBER:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位
  • LOCATION:頻道所在位置;請使用支援的區域之一
    顯示地區
    • 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:管道的使用者定義 ID
  • CLIP_ID:隨選影片短片的使用者定義 ID

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/clips/CLIP_ID",
  "createTime": CREATE_TIME,
  "startTime": START_TIME,
  "updateTime": UPDATE_TIME,
  "state": "SUCCEEDED",
  "outputUri": "gs://BUCKET_NAME",
  "slices": [
    {
      "timeSlice": {
        "markinTime": "MARK_IN_TIME",
        "markoutTime": "MARK_OUT_TIME"
      }
    }
  ],
  "features": {},
  "clipManifests": [
    {
      "manifestKey": "manifest_hls",
      "outputUri": "gs://BUCKET_NAME/main.m3u8"
    }
  ]
}

使用 projects.locations.channels.clips.get 方法時,系統只會提供每個頻道最近的 1000 個短片工作記錄。系統會移除超過上限的所有短片工作記錄。您必須管理由 outputUri 指定的產生短片檔案;Live Stream API 不會從 Cloud Storage 刪除這些檔案。

列出頻道短片

如要列出為管道建立的所有管道短片,請使用 projects.locations.channels.clips.list 方法。

使用任何要求資料之前,請先替換以下項目:

  • PROJECT_NUMBER:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位
  • LOCATION:頻道所在位置;請使用支援的區域之一
    顯示地區
    • 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:管道的使用者定義 ID

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

{
    "clips": [
      {
        "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/clips/CLIP_ID",
        "createTime": CREATE_TIME,
        "startTime": START_TIME,
        "updateTime": UPDATE_TIME,
        "state": "SUCCEEDED",
        "outputUri": "gs://BUCKET_NAME",
        "slices": [
          {
            "timeSlice": {
              "markinTime": "MARK_IN_TIME",
              "markoutTime": "MARK_OUT_TIME"
            }
          }
        ],
        "features": {},
        "clipManifests": [
          {
            "manifestKey": "manifest_hls",
            "outputUri": "gs://BUCKET_NAME/main.m3u8"
          }
        ]
      },
      {
        "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID/clips/my-clip2",
        "createTime": CREATE_TIME,
        "startTime": START_TIME,
        "updateTime": UPDATE_TIME,
        "state": "SUCCEEDED",
        "outputUri": "gs://BUCKET_NAME",
        "slices": [
          {
            "timeSlice": {
              "markinTime": "MARK_IN_TIME",
              "markoutTime": "MARK_OUT_TIME"
            }
          }
        ],
        "features": {},
        "clipManifests": [
          {
            "manifestKey": "manifest_hls",
            "outputUri": "gs://BUCKET_NAME/main.m3u8"
          }
        ]
      }
  ]
}

刪除管道短片

如要刪除管道短片,請使用 projects.locations.channels.clips.delete 方法。這個方法只會刪除剪報工作。在 Cloud Storage 值區中建立的 VOD 資源不會由 Live Stream API 管理,也不會遭到刪除。

使用任何要求資料之前,請先替換以下項目:

  • PROJECT_NUMBER:您的 Google Cloud 專案編號,位於 IAM 設定頁面上的「專案編號」欄位
  • LOCATION:頻道所在位置;請使用支援的區域之一
    顯示地區
    • 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:管道的使用者定義 ID
  • CLIP_ID:隨選影片短片的使用者定義 ID

如要傳送要求,請展開以下其中一個選項:

您應該會收到如下的 JSON 回應:

{
  "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/clips/CLIP_ID",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

這個指令會建立長期執行作業 (LRO),您可以使用該作業追蹤要求的進度。詳情請參閱「管理長時間執行的作業 」。