本頁說明如何在建立輸入端點或頻道時,設定直播功能的相關設定,例如多個音軌、字幕和圖像片集。
透過建立輸入端點進行設定
您可以在建立輸入端點時,為下列功能指定設定:
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"
}
}
Sprite 工作表
如要產生圖塊區塊,請在 Channel
資源中設定 spriteSheets
欄位。
{
"spriteSheets": [
{
"format": "jpeg",
"filePrefix": "sprite",
"interval": "2s",
"spriteWidthPixels": 320,
"spriteHeightPixels": 240,
"columnCount": 3,
"rowCount": 3,
"quality": 80
}
]
}