建立 IVS 頻道的 CLI 說明
使用 AWS CLI 建立頻道是進階選項,需要您先在機器上下載並設定 CLI。如需詳細資訊,請參閱 AWS 命令列界面使用者指南。
根據您要建立具備錄製功能或不具備錄製功能的頻道,請執行下列兩項程序之一。
建立沒有錄製功能的頻道
-
執行
create-channel
命令並傳入選用名稱:aws ivs create-channel --name test-channel
-
這將返回一個新的頻道:
{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "authorized": false, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "latencyMode": "LOW", "name": "channel-live", "playbackRestrictionPolicyArn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/abcdABCDefgh", "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "recordingConfigurationArn": "none", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase: "ZU5A3yrjGAkghUNDr0c5NXBhsPrjlmtcKMNBluh7oImwJQ3ijeyClvMKxlpPcGAMziICJ", }, "tags": {}, "type": "STANDARD" }, "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/g1H2I3j4k5L6", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {}, "value": "sk_us-west-2_abcdABCDefgh_567890abcdef" } }
-
重要:請注意
ingestEndpoint
、streamKey value
和playbackUrl
。您將使用它們來設定串流和播放。
建立具有錄製功能的頻道
必要條件:開始此程序之前,請建立 Amazon S3 儲存貯體並注意其 ARN。請參閱 Amazon S3 入門。S3 儲存貯體必須位於您要建立錄製組態的相同區域;請參閱下面步驟 1 中的已知問題。
然後依照以下步驟來建立頻道:
-
執行
create-recording-configuration
命令並傳入現有 Amazon S3 儲存貯體的 ARN:aws ivs create-recording-configuration --name configuration-1 --destination-configuration s3={bucketName=test-bucket}
除此之外,您亦可傳遞
thumbnail-configuration
參數,手動設定縮圖錄製模式和縮圖間隔:aws ivs create-recording-configuration --name configuration-1 --destination-configuration s3={bucketName=s3_bucket_name} --thumbnail-configuration recordingMode="INTERVAL",targetIntervalSeconds=60
可選擇傳送
recording-reconnect-window-seconds
參數以啟用分段串流的合併功能:aws ivs create-recording-configuration --name configuration-1 --destination-configuration s3={bucketName=test-bucket} --recording-reconnect-window-seconds 60
已知問題:在 us-east-1 區域中,如果您使用 AWS CLI 建立錄製組態,即使 S3 儲存貯體位於其他區域,也會傳回成功。在此情況下,錄製組態的
state
為CREATE_FAILED
(而非ACTIVE
)。(在其他區域中,如果儲存貯體位於不同區域,CLI 會正確傳回失敗。)解決方法:確定您的 S3 儲存貯體與錄製組態位於相同的區域。如果您在不同區域建立錄製組態作為您的 S3 儲存貯體,請刪除該錄製組態,並從正確區域使用 S3 儲存貯體建立新的錄製組態。
-
這會傳回具有唯一 ARN 的新錄製組態。錄製組態的狀態為
CREATING
,表示正在建立過程中。{ "recordingConfiguration": { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te", "name": "configuration-1", "destinationConfiguration": { "s3": { "bucketName": "s3_bucket_name" } }, "recordingReconnectWindowSeconds": 60, "state": "CREATING", "tags": {}, "thumbnailConfiguration": { "recordingMode": "INTERVAL", "targetIntervalSeconds": 60 } } }
-
通常,建立錄製組態需要幾秒鐘,但最多可能需要 20 秒鐘。若要檢查錄製組態是否已建立,請執行
get-recording-configuration
命令:aws ivs get-recording-configuration --arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te"
-
這將傳回一個回應,指示已建立錄製組態 (
state
為ACTIVE
):{ "recordingConfiguration": { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te", "name": "configuration-1", "destinationConfiguration": { "s3": { "bucketName": "s3_bucket_name" } }, "recordingReconnectWindowSeconds": 60, "state": "ACTIVE", "tags": {}, "thumbnailConfiguration": { "recordingMode": "INTERVAL", "targetIntervalSeconds": 60 } } }
-
若要建立頻道並啟用錄製功能,請執行
create-channel
命令並傳入錄製組態 ARN:aws ivs create-channel --name channel-live --recording-configuration-arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te"
或者,若要在現有頻道上啟用錄製功能,請執行
update-channel
命令並傳入錄製組態 ARN:aws ivs update-channel --arn "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh" --recording-configuration-arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te"
-
這會傳回一個頻道物件,
recordingConfigurationArn
的值為非 none 值,表示錄製已啟用。(下面的回應來自create-channel
。所以此update-channel
回應不包含streamKey
物件)。{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "authorized": false, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "latencyMode": "LOW", "name": "channel-live", "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase: "ZU5A3yrjGAkghUNDr0c5NXBhsPrjlmtcKMNBluh7oImwJQ3ijeyClvMKxlpPcGAMziICJ", }, "tags": {}, "type": "STANDARD" }, "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/g1H2I3j4k5L6", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {}, "value": "sk_us-west-2_abcdABCDefgh_567890abcdef" } }
-
重要:請注意
ingestEndpoint
、streamKey value
和playbackUrl
。您將使用它們來設定串流和播放。