將直播發布至遠端端點

本頁說明如何使用安全可靠傳輸 (SRT) 通訊協定或即時訊息傳遞通訊協定 (RTMP),將即時串流輸出內容發布至遠端端點。在推送模式中,系統會使用 SRT 和 RTMP 將串流傳送至端點。SRT 支援的容器格式為 MPEG-TS,RTMP 則為 FLV。

事前準備

本頁面假設您已完成 HLS 直播快速入門的「開始前」一節中的步驟。

視選擇的發布通訊協定而定,在要以推送模式接收輸出的供應商上,建立 SRT 或 RTMP 端點。端點 URI 格式會因通訊協定而異:

  • SRT: srt://SRT_SERVER_IP:SRT_SERVER_PORT?streamid=SRT_SERVER_STREAM_ID
  • RTMP: rtmp://RTMP_SERVER_IP:RTMP_SERVER_PORT/RTMP_APP_NAME/RTMP_STREAM_KEY 或僅 rtmp://RTMP_SERVER_IP:RTMP_SERVER_PORT/RTMP_APP_NAME

SRT_SERVER_IPRTMP_SERVER_IP 可以是 IP 位址或網域名稱。

建立輸入端點

如要建立輸入端點,請使用 projects.locations.inputs.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
  • INPUT_ID:為要建立的新輸入端點定義的 ID (您會將輸入串流傳送至該端點)。這個值必須介於 1 至 63 個字元之間,開頭和結尾須為 [a-z0-9],且字元之間可包含破折號 (-)。例如:my-input

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

您應該會收到如下的 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/inputs/INPUT_ID",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

複製傳回的 OPERATION_ID,以便在下一節中使用。

查看結果

使用 projects.locations.operations.get 方法檢查輸入端點是否已建立。如果回應包含 "done: false",請重複執行指令,直到回應包含 "done: true" 為止。在區域中建立第一個輸入端點最多可能需要 10 分鐘。

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

  • 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
  • OPERATION_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,
    "endTime": END_TIME,
    "target": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": true,
  "response": {
    "@type": "type.googleapis.com/google.cloud.video.livestream.v1.Input",
    "name": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID",
    "createTime": CREATE_TIME,
    "updateTime": UPDATE_TIME,
    "type": "RTMP_PUSH",
    "uri":  INPUT_STREAM_URI, # For example, "rtmp://1.2.3.4/live/b8ebdd94-c8d9-4d88-a16e-b963c43a953b",
    "tier": "HD"
  }
}

找到 uri 欄位,然後複製傳回的 INPUT_STREAM_URI,以便稍後在「傳送輸入串流」部分使用。

建立頻道

如要建立管道,請使用 projects.locations.channels.create 方法。

請注意管道設定中的下列事項:

  • distributionStreams 陣列包含發布內容的串流多工設定。
  • 每個 DistributionStream 物件都必須包含 keycontainerelementaryStreams 欄位。

    {
      "distributionStreams": [
        {
          "key": "ds1",
          "container": "ts", // to be used with an SRT distribution
          "elementaryStreams": [
            "es_video_720",
            "es_audio"
          ]
        },
        {
          "key": "ds2",
          "container": "flv", // to be used with an RTMP distribution
          "elementaryStreams": [
            "es_video_640",
            "es_audio"
          ]
        }
      ]
    }
    
  • distributions 陣列會列出發布設定,包括遠端端點。

  • Distribution 物件中的 distributionStream 欄位設為 DistributionStream 物件的 key

  • 如要設定 SRT 發布,請在 SrtPushOutputEndpoint 物件中將 uri 設為您建立的 SRT 端點。如要透過 RTMP 發布,請在 RtmpPushOutputEndpoint 物件中,將 uri 設為您建立的 RTMP 端點

    {
      "distributions": [
        {
          "key": "pd1",
          "distributionStream": "ds1", // defined in a distributionStreams[] object with an MPEG-TS container
          "srtPush": {
            "uri": "srt://SRT_SERVER_IP:SRT_SERVER_PORT?streamid=SRT_SERVER_STREAM_ID"
          }
        },
        {
          "key": "pd2",
          "distributionStream": "ds2", // defined in a distributionStreams[] object with an FLV container
          "rtmpPush": {
            "uri": "rtmp://RTMP_SERVER_IP:RTMP_SERVER_PORT/RTMP_APP_NAME/",
            "streamKey": "RTMP_STREAM_KEY"
          }
        }
      ]
    }
    
  • 如要發布 AI 生成的字幕和翻譯字幕,請參閱設定自動字幕和翻譯指南。

下列範例只使用一個 DistributionStream 物件和一個 Distribution 物件。

REST

SRT

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

  • 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;這個值必須介於 1 至 63 個字元之間,開頭和結尾須為 [a-z0-9],且字元之間可包含破折號 (-)
  • INPUT_ID:輸入端點的使用者定義 ID
  • BUCKET_NAME:您建立的 Cloud Storage bucket 名稱,用於保存即時串流資訊清單和區隔檔案
  • SRT_SERVER_IP:遠端端點的 IP 位址或網域名稱
  • SRT_SERVER_PORT:遠端端點的通訊埠號碼
  • SRT_SERVER_STREAM_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",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

RTMP

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

  • 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;這個值必須介於 1 至 63 個字元之間,開頭和結尾須為 [a-z0-9],且字元之間可包含破折號 (-)
  • INPUT_ID:輸入端點的使用者定義 ID
  • BUCKET_NAME:您建立的 Cloud Storage bucket 名稱,用於保存即時串流資訊清單和區隔檔案
  • RTMP_SERVER_IP:遠端端點的 IP 位址或網域名稱
  • RTMP_SERVER_PORT:遠端端點的通訊埠號碼
  • RTMP_APP_NAME:串流名稱的路徑前置字串
  • RTMP_STREAM_KEY:遠端端點的串流金鑰

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

您應該會收到如下的 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",
    "verb": "create",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的作業 ID 檢查作業結果

取得頻道

建立管道後,請使用 projects.locations.channels.get 方法查詢管道狀態。

REST

SRT

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

  • 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 回應:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "inputAttachments": [
    {
      "key": "INPUT_ID",
      "input": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID"
    }
  ],
  "activeInput": "INPUT_ID",
  "output": {
    "uri": "gs://BUCKET_NAME"
  },
  "elementaryStreams": [
    {
      "videoStream": {
        "h264": {
          "widthPixels": 1280,
          "heightPixels": 720,
          "frameRate": 30,
          "bitrateBps": 3000000,
          "gopDuration": "2s",
          "vbvSizeBits": 3000000,
          "vbvFullnessBits": 2700000,
          "entropyCoder": "cabac",
          "profile": "high"
        }
      },
      "key": "es_video"
    },
    {
      "audioStream": {
        "codec": "aac",
        "bitrateBps": 160000,
        "channelCount": 2,
        "sampleRateHertz": 48000
      },
      "key": "es_audio"
    }
  ],
  "muxStreams": [
    {
      "key": "mux_video_ts",
      "container": "ts",
      "elementaryStreams": [
        "es_video",
        "es_audio"
      ],
      "segmentSettings": {
        "segmentDuration": "2s"
      }
    }
  ],
  "manifests": [
    {
      "fileName": "main.m3u8",
      "type": "HLS",
      "muxStreams": [
        "mux_video_ts"
      ],
      "maxSegmentCount": 5,
      "segmentKeepDuration": "60s",
      "key": "manifest_hls"
    }
  ],
  "streamingState": "STOPPED",
  "distributionStreams": [
    {
      "key": "ds1",
      "container": "ts",
      "elementaryStreams": [
        "es_video",
        "es_audio"
      ]
    }
  ],
  "distributions": [
    {
      "key": "pd1",
      "distributionStream": "ds1",
      "state": "NOT_READY",
      "srtPush": {
        "uri": "srt://SRT_SERVER_IP:SRT_SERVER_PORT?streamid=SRT_SERVER_STREAM_ID"
      }
    }
  ]
}

RTMP

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

  • 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 回應:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/channels/CHANNEL_ID",
  "createTime": CREATE_TIME,
  "updateTime": UPDATE_TIME,
  "inputAttachments": [
    {
      "key": "INPUT_ID",
      "input": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID"
    }
  ],
  "activeInput": "INPUT_ID",
  "output": {
    "uri": "gs://BUCKET_NAME"
  },
  "elementaryStreams": [
    {
      "videoStream": {
        "h264": {
          "widthPixels": 1280,
          "heightPixels": 720,
          "frameRate": 30,
          "bitrateBps": 3000000,
          "gopDuration": "2s",
          "vbvSizeBits": 3000000,
          "vbvFullnessBits": 2700000,
          "entropyCoder": "cabac",
          "profile": "high"
        }
      },
      "key": "es_video"
    },
    {
      "audioStream": {
        "codec": "aac",
        "bitrateBps": 160000,
        "channelCount": 2,
        "sampleRateHertz": 48000
      },
      "key": "es_audio"
    }
  ],
  "muxStreams": [
    {
      "key": "mux_video_ts",
      "container": "ts",
      "elementaryStreams": [
        "es_video",
        "es_audio"
      ],
      "segmentSettings": {
        "segmentDuration": "2s"
      }
    }
  ],
  "manifests": [
    {
      "fileName": "main.m3u8",
      "type": "HLS",
      "muxStreams": [
        "mux_video_ts"
      ],
      "maxSegmentCount": 5,
      "segmentKeepDuration": "60s",
      "key": "manifest_hls"
    }
  ],
  "streamingState": "STOPPED",
  "distributionStreams": [
    {
      "key": "ds1",
      "container": "flv",
      "elementaryStreams": [
        "es_video",
        "es_audio"
      ]
    }
  ],
  "distributions": [
    {
      "key": "pd1",
      "distributionStream": "ds1",
      "state": "NOT_READY",
      "rtmpPush": {
        "uri": "rtmp://RTMP_SERVER_IP:RTMP_SERVER_PORT/RTMP_APP_NAME",
        "streamKey": "RTMP_STREAM_KEY"
      }
    }
  ]
}

完整回應包含下列欄位:

{
  ...
  "streamingState": "STOPPED",
  "distributions": [
    {
      ...
      "state": "NOT_READY"
      ...
    }
  ]
  ...
}

這項回應會指出頻道的串流狀態和頻道發布情形。

如果發布作業處於 NOT_READY 狀態,就無法啟動。你必須等到狀態變更為 READY,才能開始發布串流。

建立第一個發布串流最多可能需要 10 分鐘。發布狀態與頻道狀態無關,您可以啟動頻道,等待發布狀態變成 READY,然後啟動發布作業。

現在可以啟動頻道。

啟動管道

使用 projects.locations.channels.start 方法啟動管道。頻道必須先啟動,才能接受輸入串流或產生輸出串流。

在區域中啟動第一個頻道約需 10 分鐘。

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

  • 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 回應:

{
  "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",
    "verb": "start",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

如要判斷頻道是否已啟動,請取得頻道資訊,做法與先前相同。回應應包含下列內容:

{
  ...
  "streamingState": "AWAITING_INPUT"
  ...
}

傳送輸入串流

開啟新的終端機視窗。使用「檢查結果」一節中的 INPUT_STREAM_URI 執行下列指令:

ffmpeg -re -f lavfi -i "testsrc=size=1280x720 [out0]; sine=frequency=500 [out1]" \
  -acodec aac -vcodec h264 -f flv INPUT_STREAM_URI

頻道現在正在播放串流內容,但發布作業仍處於停止狀態。

開始發放

發布內容必須處於 READY 狀態才能啟動。如要開始將直播輸出內容發布至所有遠端端點,請使用 projects.locations.channels.startdistribution 方法。

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

  • 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 回應:

{
  "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",
    "verb": "startdistribution",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的作業 ID 檢查作業結果。啟動發布作業後,如果輸入串流尚未啟動,則會處於 AWAITING_INPUT 狀態;如果輸入串流正在發布至指定端點,則會處於 DISTRIBUTING 狀態。

(選用) 開始發放

您可以一次發布一組,不必一次發布所有內容。列出要啟動的發布項目,方法是將這些項目的鍵新增至 distributionKeys 陣列清單。

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

  • 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
  • DISTRIBUTION_KEYS:以半形逗號分隔的字串鍵清單 (例如 "pd1")

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

您應該會收到如下的 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",
    "verb": "startdistribution",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的作業 ID 檢查作業結果

確認發布作業正在執行

如要確認發布作業已開始,請取得頻道資訊,做法與先前相同。回應應包含下列內容:

{
  "distributions": [
    {
      ...
      "state": "DISTRIBUTING"
      ...
    },
    ...
  ]
}

在遠端 SRT 或 RTMP 伺服器上,確認您建立的端點正在接收資料。

停止發布

如要停止將直播輸出內容發布至所有遠端端點,請使用 projects.locations.channels.stopdistribution 方法。

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

  • 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 回應:

{
  "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",
    "verb": "stopdistribution",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的作業 ID 檢查作業結果

(選用) 停止一組發布作業

你可以停止一組發布作業,不必一次停止所有作業。將要停止的發布項目鍵新增至 distributionKeys 陣列清單,列出這些發布項目。

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

  • 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
  • DISTRIBUTION_KEYS:以半形逗號分隔的字串鍵清單 (例如 "pd1")

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

您應該會收到如下的 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",
    "verb": "stopdistribution",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的作業 ID 檢查作業結果

支援 SRT 加密

如果使用 SRT 通訊協定將直播輸出內容發布至遠端端點,Live Stream API 會以 AES 加密保護直播內容。

建立密碼片語並準備遠端 SRT 伺服器

開始前,請先建立符合遠端 SRT 伺服器的 SRT 密碼片語。通常,密碼片語應為 10 到 79 個字元的字串。

在遠端 SRT 伺服器中設定相同的密碼片語,確保解密程序正常運作。如需操作說明,請參閱遠端 SRT 伺服器的使用手冊。

將密碼片語新增至 Secret Manager

Live Stream API 不會直接接受或管理密碼片語。 你必須透過 Google Secret Manager,將密碼片語提供給 Live Stream API。

設定頻道前,請務必完成下列所有步驟:

  1. 使用 Secret Manager 建立密鑰。
  2. 設定密鑰的 Identity and Access Management 權限,讓 Live Stream API 可以存取密鑰內容。如要這麼做,請將 secretmanager.secretAccessor 角色授予 service-PROJECT_NUMBER@gcp-sa-livestream.iam.gserviceaccount.com 服務帳戶 (這與服務帳戶存取 Cloud Storage bucket 的方式類似)。
  3. 找出您建立的密鑰版本資源名稱 (例如 projects/PROJECT_NUMBER/secrets/SECRET_ID/versions/VERSION_ID)。設定管道時需要這個名稱。

設定管道

密碼片語的密鑰版本是在 SrtPushOutputEndpoint 中指定:

{
  "distributions": [
    {
      "key": "pd1",
      "distributionStream": "ds1", // defined in a distributionStreams[] object with an MPEG-TS container
      "srtPush": {
        "uri": "srt://{SRT_SERVER_IP}:{SRT_SERVER_PORT}?streamid={SRT_SERVER_STREAM_ID}",
        "passphrase_secret_version": "projects/PROJECT_NUMBER/secrets/key1/versions/1"
      }
    }
  ]
}

清除所用資源

如要避免系統向您的 Google Cloud 帳戶收取本頁所用資源的費用,請按照下列步驟操作。

停止管道

使用 projects.locations.channels.stop 方法停止頻道。你必須先停止頻道,才能刪除。

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

  • 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 回應:

{
  "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",
    "verb": "stop",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的作業 ID 檢查作業結果

停止輸入串流

如果使用 ffmpeg 傳送輸入串流,停止頻道後,連線會自動中斷。

刪除頻道

使用 projects.locations.channels.delete 方法刪除頻道。您必須先刪除頻道,才能刪除頻道使用的輸入端點。

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

  • 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 回應:

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

您可以使用新的作業 ID 檢查作業結果

刪除輸入端點

使用 projects.locations.inputs.delete 方法刪除輸入端點。

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

  • 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
  • INPUT_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/inputs/INPUT_ID",
    "verb": "delete",
    "requestedCancellation": false,
    "apiVersion": "v1"
  },
  "done": false
}

您可以使用新的作業 ID 檢查作業結果

刪除 Cloud Storage 值區

  1. 前往 Google Cloud 控制台的 Cloud Storage 瀏覽器頁面。

    前往 Cloud Storage 瀏覽器頁面

  2. 找出您建立的值區,並選取旁邊的核取方塊。

  3. 點選「刪除」。

  4. 在隨即顯示的對話方塊中,按一下「刪除」,即可刪除值區及其內容。