本页介绍了如何在输入端点或频道创建期间为直播功能(例如多个音轨、字幕和精灵图集)配置设置。
通过创建输入端点进行配置
您可以在创建输入端点期间为以下功能指定配置:
制定 IP 许可名单
您可以通过指定输入串流应来自的 IP 地址范围(例如编码器的 IP 地址)来限制对输入端点的访问。视频流水线仅接受来自这些 IP 地址范围的流量。IP 地址范围必须采用 CIDR 地址块格式。
在 Input
资源中配置 securityRules
字段:
{
"type": "RTMP_PUSH",
"securityRules": {
"ipRanges": ["1.2.3.4/32"]
}
}
通过创建频道进行配置
您可以在创建渠道期间为以下功能指定配置:
多个比特率串流
您可以创建支持多种比特率、分辨率和帧速率的高级频道配置。以下配置在输出中包含两个 muxStream
,一个为 360p,帧速率为 30 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": [
{
"key": "manifest_dash",
"fileName": "main.mpd",
"type": "DASH",
"muxStreams": [
"mux_video_720p60",
"mux_video_360p30",
"mux_audio_160k",
"mux_audio_64k"
],
"maxSegmentCount": 5
},
{
"key": "manifest_hls",
"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": [
{
"key": "manifest_dash",
"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
}
]
}