使用 Zencoder 與谷歌雲存儲

本主題介紹在 Google Cloud Platform 上使用 Zencoder 的設置。

谷歌云存儲設置

按照以下步驟在 Google Cloud Platform 上使用 Zencoder。

  1. 轉到雲存儲設置並單擊 互操作性 選項卡:
    互操作性選項卡
    互操作性選項卡
  2. 在用戶帳戶 HMAC 中,選擇您的項目作為默認項目,然後單擊 創建密鑰
    創建訪問密鑰
    創建訪問密鑰
  3. 保存 Access Key 和 Secret 以便稍後在 Zencoder 中輸入。
  4. 針對allAuthenticatedUsers使用儲存物件檢視器角色,在值區層級的權限上新增主體。您需要激活 public to internet 選項。
    添加新校長
    添加新校長
  5. 在 Zencoder Dashboard 的 Credentials 部分將 訪問密鑰秘密 添加到 Zencoder:
    在 Zencoder 中輸入憑證
    在 Zencoder 中輸入憑證

轉碼

下面的示例顯示了一個工作作業,它從 GCS 中提取輸入視頻,為 HTTP Live Streaming 創建再現,並將輸出流發送到 GCS。您可以通過更改my-bucket為您擁有的現有 GCS 存儲桶並將其粘貼到請求生成器中進行測試

使用 GCS 的示例 HLS 作業

  {
      "test": true,
      "input": "gcs://zencoder-testing/test.mov",
      "output": [
      {
          "audio_bitrate": 64,
          "audio_sample_rate": 22050,
          "base_url": "gcs://my-bucket/",
          "filename": "file-64k.m3u8",
          "segment_seconds": 2,
          "format": "aac",
          "headers":{
              "x-goog-acl": "public-read"
          },
          "type": "segmented"
      },
      {
          "audio_bitrate": 56,
          "audio_sample_rate": 22050,
          "base_url": "gcs://my-bucket/",
          "decoder_bitrate_cap": 360,
          "decoder_buffer_size": 840,
          "filename": "file-240k.m3u8",
          "segment_seconds": 2,
          "max_frame_rate": 15,
          "type": "segmented",
          "video_bitrate": 184,
          "headers":{
              "x-goog-acl": "public-read"
          },
          "width": 400,
          "format": "ts"
      },
      {
          "audio_bitrate": 56,
          "audio_sample_rate": 22050,
          "base_url": "gcs://my-bucket/",
          "decoder_bitrate_cap": 578,
          "decoder_buffer_size": 1344,
          "filename": "file-440k.m3u8",
          "segment_seconds": 2,
          "type": "segmented",
          "video_bitrate": 384,
          "headers":{
              "x-goog-acl": "public-read"
          },
          "width": 400,
          "format": "ts"
      },
      {
          "audio_bitrate": 56,
          "audio_sample_rate": 22050,
          "base_url": "gcs://my-bucket/",
          "decoder_bitrate_cap": 960,
          "decoder_buffer_size": 2240,
          "filename": "file-640k.m3u8",
          "segment_seconds": 2,
          "type": "segmented",
          "video_bitrate": 584,
          "headers":{
              "x-goog-acl": "public-read"
          },
          "width": 480,
          "format": "ts"
      },
      {
          "audio_bitrate": 56,
          "audio_sample_rate": 22050,
          "base_url": "gcs://my-bucket/",
          "decoder_bitrate_cap": 1500,
          "decoder_buffer_size": 4000,
          "filename": "file-1040k.m3u8",
          "segment_seconds": 2,
          "type": "segmented",
          "video_bitrate": 1000,
          "headers":{
              "x-goog-acl": "public-read"
          },
          "width": 640,
          "format": "ts"
      },
      {
          "audio_bitrate": 56,
          "audio_sample_rate": 22050,
          "base_url": "gcs://my-bucket/",
          "decoder_bitrate_cap": 2310,
          "decoder_buffer_size": 5390,
          "filename": "file-1540k.m3u8",
          "segment_seconds": 2,
          "type": "segmented",
          "video_bitrate": 1484,
          "headers":{
              "x-goog-acl": "public-read"
          },
          "width": 960,
          "format": "ts"
      },
      {
          "audio_bitrate": 56,
          "audio_sample_rate": 22050,
          "base_url": "gcs://my-bucket/",
          "decoder_bitrate_cap": 3060,
          "decoder_buffer_size": 7140,
          "filename": "file-2040k.m3u8",
          "segment_seconds": 2,
          "type": "segmented",
          "video_bitrate": 1984,
          "headers":{
              "x-goog-acl": "public-read"
          },
          "width": 1024,
          "format": "ts"
      },
      {
          "base_url": "gcs://my-bucket/",
          "filename": "playlist.m3u8",
          "streams": [
          {
              "bandwidth": 2040,
              "path": "file-2040k.m3u8"
          },
          {
              "bandwidth": 1540,
              "path": "file-1540k.m3u8"
          },
          {
              "bandwidth": 1040,
              "path": "file-1040k.m3u8"
          },
          {
              "bandwidth": 640,
              "path": "file-640k.m3u8"
          },
          {
              "bandwidth": 440,
              "path": "file-440k.m3u8"
          },
          {
              "bandwidth": 240,
              "path": "file-240k.m3u8"
          },
          {
              "bandwidth": 64,
              "path": "file-64k.m3u8"
          }
          ],
          "headers":{
              "x-goog-acl": "public-read"
          },
          "type": "playlist"
      }
      ]
  }