配置直播设置

使用集合让一切井井有条 根据您的偏好保存内容并对其进行分类。

本页面介绍了如何在输入端点或频道创建期间为多个音轨、字幕和精灵表等直播功能配置设置。

通过创建输入端点进行配置

您可以在创建输入端点期间为以下功能指定配置:

制定 IP 许可名单

您可以通过指定输入流的来源 IP 地址范围(例如编码器的 IP 地址)来限制对输入端点的访问。视频流水线仅接受来自这些范围内的 IP 地址的流量。IP 范围必须采用 CIDR 块格式。

配置 Input 资源中的 securityRules 字段:

{
  "type": "RTMP_PUSH",
  "securityRules": {
    "ipRanges": ["1.2.3.4/32"]
  }
}

通过创建渠道进行配置

您可以在创建频道期间为以下功能指定配置:

多个比特率流

您可以创建支持多种比特率、分辨率和帧速率的高级信道配置。以下配置在输出中包含两个 muxStream,一个帧速率为 300 FPS (mux_video_360p30),另一个分辨率为 720p,帧速率为 60 FPS (mux_video_720p60)。此配置还支持多种音频比特率。如需了解详情,请参阅建议的比特率

{
  "inputAttachments":[
    {
      "key":"input-primary",
      "input": "projects/PROJECT_NUMBER/locations/LOCATION/inputs/INPUT_ID"
    }
  ],
  "output":{
    "uri": "gs://BUCKET_NAME"
  },
  "elementaryStreams": [
    {
      "key": "es_video_720p60",
      "videoStream": {
        "h264": {
          "profile": "high",
          "heightPixels": 720,
          "widthPixels": 1280,
          "bitrateBps": 5500000,
          "frameRate": 60
        }
      }
    },
    {
      "key": "es_video_360p30",
      "videoStream": {
        "h264": {
          "profile": "high",
          "heightPixels": 360,
          "widthPixels": 640,
          "bitrateBps": 400000,
          "frameRate": 30
        }
      }
    },
    {
      "key": "es_audio_160k",
      "audioStream": {
        "codec": "aac",
        "channelCount": 2,
        "bitrateBps": 160000
      }
    },
    {
      "key": "es_audio_64k",
      "audioStream": {
        "codec": "aac",
        "channelCount": 2,
        "bitrateBps": 64000
      }
    }
  ],
  "muxStreams": [
    {
      "key": "mux_video_720p60",
      "elementaryStreams": [
        "es_video_720p60"
      ],
      "segmentSettings": {
        "segmentDuration": "2s"
      }
    },
    {
      "key": "mux_video_360p30",
      "elementaryStreams": [
        "es_video_360p30"
      ],
      "segmentSettings": {
        "segmentDuration": "2s"
      }
    },
    {
      "key": "mux_audio_160k",
      "elementaryStreams": [
        "es_audio_160k"
      ],
      "segmentSettings": {
        "segmentDuration": "2s"
      }
    },
    {
      "key": "mux_audio_64k",
      "elementaryStreams": [
        "es_audio_64k"
      ],
      "segmentSettings": {
        "segmentDuration": "2s"
      }
    }
  ],
  "manifests": [
    {
      "fileName": "main.mpd",
      "type": "DASH",
      "muxStreams": [
        "mux_video_720p60",
        "mux_video_360p30",
        "mux_audio_160k",
        "mux_audio_64k"
      ],
      "maxSegmentCount": 5
    },
    {
      "fileName": "main.m3u8",
      "type": "HLS",
      "muxStreams": [
        "mux_video_720p60",
        "mux_video_360p30",
        "mux_audio_160k",
        "mux_audio_64k"
      ],
      "maxSegmentCount": 5
    }
  ]
}

多个音轨

如果输入流包含多个音轨,请使用 AudioMapping 对象为每个 AudioStream 选择音轨。

{
  "inputAttachments": [
    {
      "key": "MY-INPUT",
      "input": "/projects/PROJECT-ID/locations/LOCATION/inputs/MY-INPUT",
    }
  ],
  "output": {
    "uri": "gs://BUCKET_NAME/outputs/"
  },
  "elementaryStreams": [
    {
      "key": "es_video",
      "videoStream": {
        "h264": {
          "heightPixels": 720,
          "widthPixels": 1280,
          "bitrateBps": 3000000,
          "frameRate": 30
        }
      }
    },
    {
      "key": "es_first_audio",
      "audioStream": {
        "codec": "aac",
        "bitrateBps": 160000,
        "mapping": [
          {
            "inputKey": "MY-INPUT",
            "inputTrack": 1
          }
        ]
      }
    },
    {
      "key": "es_second_audio",
      "audioStream": {
        "codec": "aac",
        "bitrateBps": 160000,
        "mapping": [
          {
            "inputKey": "MY-INPUT",
            "inputTrack": 2
          }
        ]
      }
    }
  ],
  "muxStreams": [
    {
      "key": "mux_video",
      "elementaryStreams": ["es_video"],
    },
    {
      "key": "mux_first_audio",
      "elementaryStreams": ["es_first_audio"],
    },
    {
      "key": "mux_second_audio",
      "elementaryStreams": ["es_second_audio"],
    }
  ],
  "manifests": [
    {
      "type": "DASH",
      "muxStreams": [
        "mux_video",
        "mux_first_audio",
        "mux_second_audio",
      ]
    }
  ]
}

请注意,Shaka Player 不支持具有多个音轨的 HLS 流的以下功能:

  • 使用 TS 片段播放备用音轨。

  • 包含 fMP4 片段的次要和备用音轨选择。

CEA 608/708 字幕

如果输入流包含 CEA 608/708 字幕,您可以将字幕转发到输出流。创建 Channel 时,将以下 textStream 添加到 elementaryStreams。此 textStream 会将 CEA 608/708 字幕嵌入到所有输出视频流和呈现内容中。

{
  "key": "captions",
  "textStream": {
    "codec": "cea608"
  }
}

雪碧图

如需生成雪碧图,请在 Channel 资源中配置 spriteSheets 字段。

{
  "spriteSheets": [
    {
      "format": "jpeg",
      "filePrefix": "sprite",
      "interval": "2s",
      "spriteWidthPixels": 320,
      "spriteHeightPixels": 240,
      "columnCount": 3,
      "rowCount": 3,
      "quality": 80
    }
  ]
}