本页面介绍了如何在输入端点或频道创建期间为直播功能(如多个音轨、字幕和精灵表)配置设置。
通过创建输入端点进行配置
您可以在创建输入端点期间为以下功能指定配置:
制定 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",
]
}
]
}
请注意,对于具有多个音轨的 HLS 流,Shaka Player 不支持以下功能:
使用 TS 片段交替播放音轨。
使用 fMP4 片段选择辅助音轨和备用音轨。
直通式 CEA 608/708 字幕
如果输入流包含 CEA 608/708 字幕,您可以将字幕转发到输出流。在创建 Channel
时,将以下 textStream
添加到 elementaryStreams
。此 textStream
会在所有输出视频流和呈现中嵌入 CEA 608/708 字幕。
{
"key": "captions",
"textStream": {
"codec": "cea608"
}
}
Sprite 工作表
如需生成雪碧图,请配置 Channel
资源中的 spriteSheets
字段。
{
"spriteSheets": [
{
"format": "jpeg",
"filePrefix": "sprite",
"interval": "2s",
"spriteWidthPixels": 320,
"spriteHeightPixels": 240,
"columnCount": 3,
"rowCount": 3,
"quality": 80
}
]
}