使用 的 Amazon IVS範例 AWS CLI - AWS Command Line Interface

本文件 AWS CLI 僅適用於 的第 1 版。如需與 第 2 版相關的文件 AWS CLI,請參閱 第 2 版使用者指南

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 的 Amazon IVS範例 AWS CLI

下列程式碼範例示範如何搭配 AWS Command Line Interface Amazon 使用 來執行動作和實作常見案例IVS。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然動作會示範如何呼叫個別服務函數,但您可以在其相關案例中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例示範如何使用 batch-get-channel

AWS CLI

若要取得多個頻道的頻道組態資訊

下列batch-get-channel範例會列出指定頻道的相關資訊。

aws ivs batch-get-channel \ --arns arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ arn:aws:ivs:us-west-2:123456789012:channel/efghEFGHijkl

輸出:

{ "channels": [ { "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-1", "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel-1.abcdEFGH.m3u8", "preset": "", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "tags": {}, "type": "STANDARD" }, { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/efghEFGHijkl", "authorized": false, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": true, "latencyMode": "LOW", "name": "channel-2", "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel-2.abcdEFGH.m3u8", "preset": "", "playbackRestrictionPolicyArn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ"", "recordingConfigurationArn": "", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "BA1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "tags": {}, "type": "STANDARD" } ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 BatchGetChannel中的 。 AWS CLI

下列程式碼範例示範如何使用 batch-get-stream-key

AWS CLI

若要取得多個串流金鑰的相關資訊

下列batch-get-stream-key範例會取得指定串流金鑰的相關資訊。

aws ivs batch-get-stream-key \ --arns arn:aws:ivs:us-west-2:123456789012:stream-key/skSKABCDefgh \ arn:aws:ivs:us-west-2:123456789012:stream-key/skSKIJKLmnop

輸出:

{ "streamKeys": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/skSKABCDefgh", "value": "sk_us-west-2_abcdABCDefgh_567890abcdef", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} }, { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/skSKIJKLmnop", "value": "sk_us-west-2_abcdABCDefgh_567890ghijkl", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} } ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

下列程式碼範例示範如何使用 batch-start-viewer-session-revocation

AWS CLI

撤銷多個頻道ARN和檢視器 ID 對的檢視器工作階段

下列batch-start-viewer-session-revocation範例會同時對多個頻道ARN和檢視器 ID 對執行工作階段撤銷。如果來電者沒有撤銷指定工作階段的許可,則請求可能會正常完成,但傳回錯誤欄位中的值。

aws ivs batch-start-viewer-session-revocation \ --viewer-sessions '[{"channelArn":"arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh1","viewerId":"abcdefg1","viewerSessionVersionsLessThanOrEqualTo":1234567890}, \ {"channelArn":"arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh2","viewerId":"abcdefg2","viewerSessionVersionsLessThanOrEqualTo":1234567890}]'

輸出:

{ "errors": [ { "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh1", "viewerId": "abcdefg1", "code": "403", "message": "not authorized", }, { "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh2", "viewerId": "abcdefg2", "code": "403", "message": "not authorized", } ] }

如需詳細資訊,請參閱《Amazon 互動式影片服務使用者指南》中的設定私有頻道

下列程式碼範例示範如何使用 create-channel

AWS CLI

範例 1:建立沒有錄製的頻道

下列create-channel範例會建立新的頻道和相關聯的串流金鑰,以開始串流。

aws ivs create-channel \ --name "test-channel" \ --no-insecure-ingest

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "authorized": false, "name": "test-channel", "latencyMode": "LOW", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "tags": {}, "type": "STANDARD" }, "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/g1H2I3j4k5L6", "value": "sk_us-west-2_abcdABCDefgh_567890abcdef", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

範例 2:若要建立已啟用錄製的頻道,請使用其指定的 RecordingConfiguration 資源 ARN

下列create-channel範例會建立新的頻道和相關聯的串流金鑰以開始串流,並設定頻道的錄製。

aws ivs create-channel \ --name test-channel-with-recording \ --insecure-ingest \ --recording-configuration-arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh"

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "test-channel-with-recording", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "BA1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": true, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "authorized": false, "tags": {}, "type": "STANDARD" }, "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/abcdABCDefgh", "value": "sk_us-west-2_abcdABCDefgh_567890abcdef", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的記錄至 Amazon S3

範例 3:使用其指定的播放限制政策建立頻道 ARN

下列create-channel範例會建立新的頻道和相關聯的串流金鑰以開始串流,並設定頻道的播放限制政策。

aws ivs create-channel \ --name test-channel-with-playback-restriction-policy \ --insecure-ingest \ --playback-restriction-policy-arn "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ"

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "test-channel-with-playback-restriction-policy", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "recordingConfigurationArn": "", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2edfGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": true, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "authorized": false, "tags": {}, "type": "STANDARD" }, "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/abcdABCDefgh", "value": "sk_us-west-2_abcdABCDefgh_567890abcdef", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

  • 如需API詳細資訊,請參閱 命令參考 CreateChannel中的 。 AWS CLI

下列程式碼範例示範如何使用 create-playback-restriction-policy

AWS CLI

建立播放限制政策

下列create-playback-restriction-policy範例會建立新的播放撤銷政策。

aws ivs create-playback-restriction-policy \ --name "test-playback-restriction-policy" \ --enable-strict-origin-enforcement \ --tags "key1=value1, key2=value2" \ --allowed-countries US MX \ --allowed-origins https://www.website1.com https://www.website2.com

輸出:

{ "playbackRestrictionPolicy": { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "allowedCountries": [ "US", "MX" ], "allowedOrigins": [ "https://www.website1.com", "https://www.website2.com" ], "enableStrictOriginEnforcement": true, "name": "test-playback-restriction-policy", "tags": { "key1": "value1", "key2": "value2" } } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

下列程式碼範例示範如何使用 create-recording-configuration

AWS CLI

若要建立 RecordingConfiguration 資源

下列create-recording-configuration範例會建立 RecordingConfiguration 資源,以啟用記錄至 Amazon S3。

aws ivs create-recording-configuration \ --name "test-recording-config" \ --recording-reconnect-window-seconds 60 \ --tags "key1=value1, key2=value2" \ --rendition-configuration renditionSelection="CUSTOM",renditions="HD" \ --thumbnail-configuration recordingMode="INTERVAL",targetIntervalSeconds=1,storage="LATEST",resolution="LOWEST_RESOLUTION" \ --destination-configuration s3={bucketName=demo-recording-bucket}

輸出:

{ "recordingConfiguration": { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABcdef34ghIJ", "name": "test-recording-config", "destinationConfiguration": { "s3": { "bucketName": "demo-recording-bucket" } }, "state": "CREATING", "tags": { "key1": "value1", "key2": "value2" }, "thumbnailConfiguration": { "recordingMode": "INTERVAL", "targetIntervalSeconds": 1, "resolution": "LOWEST_RESOLUTION", "storage": [ "LATEST" ] }, "recordingReconnectWindowSeconds": 60, "renditionConfiguration": { "renditionSelection": "CUSTOM", "renditions": [ "HD" ] } } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的錄製至 Amazon S3

下列程式碼範例示範如何使用 create-stream-key

AWS CLI

若要建立串流金鑰

下列create-stream-key範例會為指定的 ARN(Amazon Resource Name) 建立串流金鑰。

aws ivs create-stream-key \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh

輸出:

{ "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/abcdABCDefgh", "value": "sk_us-west-2_abcdABCDefgh_567890abcdef", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 CreateStreamKey中的 。 AWS CLI

下列程式碼範例示範如何使用 delete-channel

AWS CLI

若要刪除頻道及其相關聯的串流金鑰

下列delete-channel範例會刪除具有指定 ARN(Amazon Resource Name) 的頻道。

aws ivs delete-channel \ --arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh

此命令不會產生輸出。

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 DeleteChannel中的 。 AWS CLI

下列程式碼範例示範如何使用 delete-playback-key-pair

AWS CLI

若要刪除指定的播放金鑰對

下列delete-playback-key-pair範例會傳回指定金鑰對的指紋。

aws ivs delete-playback-key-pair \ --arn arn:aws:ivs:us-west-2:123456789012:playback-key/abcd1234efgh

此命令不會產生輸出。

如需詳細資訊,請參閱《Amazon 互動式影片服務使用者指南》中的設定私有頻道

下列程式碼範例示範如何使用 delete-playback-restriction-policy

AWS CLI

若要刪除播放限制政策

下列delete-playback-restriction-policy範例會刪除具有指定政策 ARN(Amazon Resource Name) 的播放撤銷政策。

aws ivs delete-playback-restriction-policy \ --arn "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ"

此命令不會產生輸出。

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

下列程式碼範例示範如何使用 delete-recording-configuration

AWS CLI

刪除其指定的 RecordingConfiguration 資源 ARN

下列delete-recording-configuration範例會刪除具有指定 RecordingConfiguration 的資源ARN。

aws ivs delete-recording-configuration \ --arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABcdef34ghIJ"

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的錄製至 Amazon S3

下列程式碼範例示範如何使用 delete-stream-key

AWS CLI

若要刪除串流金鑰

下列delete-stream-key範例會刪除指定 ARN(Amazon Resource Name) 的串流金鑰,因此無法再用來串流。

aws ivs delete-stream-key \ --arn arn:aws:ivs:us-west-2:123456789012:stream-key/g1H2I3j4k5L6

此命令不會產生輸出。

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 DeleteStreamKey中的 。 AWS CLI

下列程式碼範例示範如何使用 get-channel

AWS CLI

若要取得頻道的組態資訊

下列get-channel範例取得指定頻道的頻道組態 ARN(Amazon Resource Name)。

aws ivs get-channel \ --arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "channel-1", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "", "preset": "", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 GetChannel中的 。 AWS CLI

下列程式碼範例示範如何使用 get-playback-key-pair

AWS CLI

若要取得指定的播放金鑰對

下列get-playback-key-pair範例會傳回指定金鑰對的指紋。

aws ivs get-playback-key-pair \ --arn arn:aws:ivs:us-west-2:123456789012:playback-key/abcd1234efgh

輸出:

{ "keyPair": { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-key/abcd1234efgh", "name": "my-playback-key", "fingerprint": "0a:1b:2c:ab:cd:ef:34:56:70:b1:b2:71:01:2a:a3:72", "tags": {} } }

如需詳細資訊,請參閱《Amazon 互動式影片服務使用者指南》中的設定私有頻道

下列程式碼範例示範如何使用 get-playback-restriction-policy

AWS CLI

若要取得播放限制政策的組態資訊

下列get-playback-restriction-policy範例取得具有指定政策 ARN(Amazon Resource Name) 的播放復原政策組態。

aws ivs get-playback-restriction-policy \ --arn "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ"

輸出:

{ "playbackRestrictionPolicy": { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "allowedCountries": [ "US", "MX" ], "allowedOrigins": [ "https://www.website1.com", "https://www.website2.com" ], "enableStrictOriginEnforcement": true, "name": "test-playback-restriction-policy", "tags": { "key1": "value1", "key2": "value2" } } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

下列程式碼範例示範如何使用 get-recording-configuration

AWS CLI

若要取得 RecordingConfiguration 資源的相關資訊

下列get-recording-configuration範例會取得指定 RecordingConfiguration 資源的相關資訊ARN。

aws ivs get-recording-configuration \ --arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABcdef34ghIJ"

輸出:

{ "recordingConfiguration": { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABcdef34ghIJ", "destinationConfiguration": { "s3": { "bucketName": "demo-recording-bucket" } }, "name": "test-recording-config", "recordingReconnectWindowSeconds": 60, "state": "ACTIVE", "tags": { "key1" : "value1", "key2" : "value2" }, "thumbnailConfiguration": { "recordingMode": "INTERVAL", "targetIntervalSeconds": 1, "resolution": "LOWEST_RESOLUTION", "storage": [ "LATEST" ] }, "renditionConfiguration": { "renditionSelection": "CUSTOM", "renditions": [ "HD" ] } } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南 中的錄製至 Amazon S3

下列程式碼範例示範如何使用 get-stream-key

AWS CLI

取得串流的相關資訊

下列get-stream-key範例取得指定串流金鑰的相關資訊。

aws ivs get-stream-key \ --arn arn:aws:ivs:us-west-2:123456789012:stream-key/skSKABCDefgh --region=us-west-2

輸出:

{ "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/skSKABCDefgh", "value": "sk_us-west-2_abcdABCDefgh_567890abcdef", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 GetStreamKey中的 。 AWS CLI

下列程式碼範例示範如何使用 get-stream-session

AWS CLI

取得指定串流的中繼資料

下列get-stream-session範例會取得指定頻道 ARN(Amazon Resource Name) 和指定串流的中繼資料組態;如果 streamId 未提供,則會選取頻道的最新串流。

aws ivs get-stream-session \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ --stream-id "mystream"

輸出:

{ "streamSession": { "streamId": "mystream1", "startTime": "2023-06-26T19:09:28+00:00", "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "mychannel", "latencyMode": "LOW", "type": "STANDARD", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABcdef34ghIJ", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "playbackUrl": "url-string", "authorized": false, "insecureIngest": false, "preset": "" }, "ingestConfiguration": { "video": { "avcProfile": "Baseline", "avcLevel": "4.2", "codec": "avc1.42C02A", "encoder": "Lavf58.45.100", "targetBitrate": 8789062, "targetFramerate": 60, "videoHeight": 1080, "videoWidth": 1920 }, "audio": { "codec": "mp4a.40.2", "targetBitrate": 46875, "sampleRate": 8000, "channels": 2 } }, "recordingConfiguration": { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABcdef34ghIJ", "name": "test-recording-config", "destinationConfiguration": { "s3": { "bucketName": "demo-recording-bucket" } }, "state": "ACTIVE", "tags": { "key1": "value1", "key2": "value2" }, "thumbnailConfiguration": { "recordingMode": "INTERVAL", "targetIntervalSeconds": 1, "resolution": "LOWEST_RESOLUTION", "storage": [ "LATEST" ] }, "recordingReconnectWindowSeconds": 60, "renditionConfiguration": { "renditionSelection": "CUSTOM", "renditions": [ "HD" ] } }, "truncatedEvents": [ { "name": "Recording Start", "type": "IVS Recording State Change", "eventTime": "2023-06-26T19:09:35+00:00" }, { "name": "Stream Start", "type": "IVS Stream State Change", "eventTime": "2023-06-26T19:09:34+00:00" }, { "name": "Session Created", "type": "IVS Stream State Change", "eventTime": "2023-06-26T19:09:28+00:00" } ] } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 GetStreamSession中的 。 AWS CLI

下列程式碼範例示範如何使用 get-stream

AWS CLI

若要取得串流的相關資訊

下列get-stream範例取得指定頻道串流的相關資訊。

aws ivs get-stream \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh

輸出:

{ "stream": { "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "startTime": "2020-05-05T21:55:38Z", "state": "LIVE", "health": "HEALTHY", "streamId": "st-ABCDEfghij01234KLMN5678", "viewerCount": 1 } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 GetStream中的 。 AWS CLI

下列程式碼範例示範如何使用 import-playback-key-pair

AWS CLI

匯入新金鑰對的公有部分

下列import-playback-key-pair範例會匯入指定的公有金鑰 (以 PEM 格式指定為字串),並傳回新金鑰對的 arn 和指紋。

aws ivs import-playback-key-pair \ --name "my-playback-key" \ --public-key-material "G1lbnQxOTA3BgNVBAMMMFdoeSBhcmUgeW91IGRl..."

輸出:

{ "keyPair": { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-key/abcd1234efgh", "name": "my-playback-key", "fingerprint": "0a:1b:2c:ab:cd:ef:34:56:70:b1:b2:71:01:2a:a3:72", "tags": {} } }

如需詳細資訊,請參閱《Amazon 互動式影片服務使用者指南》中的設定私有頻道

下列程式碼範例示範如何使用 list-channels

AWS CLI

範例 1:取得所有頻道的摘要資訊

下列list-channels範例會列出您 AWS 帳戶的所有頻道。

aws ivs list-channels

輸出:

{ "channels": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "channel-1", "latencyMode": "LOW", "authorized": false, "insecureIngest": false, "preset": "", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh", "tags": {}, "type": "STANDARD" }, { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/efghEFGHijkl", "name": "channel-2", "latencyMode": "LOW", "authorized": false, "preset": "", "playbackRestrictionPolicyArn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "recordingConfigurationArn": "", "tags": {}, "type": "STANDARD" } ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

範例 2:若要取得所有頻道的摘要資訊,請根據指定的 進行篩選 RecordingConfiguration ARN

下列list-channels範例會列出與指定 相關聯的 AWS 帳戶的所有頻道 RecordingConfiguration ARN。

aws ivs list-channels \ --filter-by-recording-configuration-arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh"

輸出:

{ "channels": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "channel-1", "latencyMode": "LOW", "authorized": false, "insecureIngest": false, "preset": "", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh", "tags": {}, "type": "STANDARD" } ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的記錄到 Amazon S3

範例 3:若要取得所有頻道的摘要資訊,請根據指定的 PlaybackRestrictionPolicy ARN

下列list-channels範例會列出與指定 相關聯的 AWS 帳戶的所有頻道 PlaybackRestrictionPolicy ARN。

aws ivs list-channels \ --filter-by-playback-restriction-policy-arn "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ"

輸出:

{ "channels": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/efghEFGHijkl", "name": "channel-2", "latencyMode": "LOW", "authorized": false, "preset": "", "playbackRestrictionPolicyArn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "recordingConfigurationArn": "", "tags": {}, "type": "STANDARD" } ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

  • 如需API詳細資訊,請參閱 命令參考 ListChannels中的 。 AWS CLI

下列程式碼範例示範如何使用 list-playback-key-pairs

AWS CLI

若要取得所有播放金鑰對的摘要資訊

下列list-playback-key-pairs範例會傳回所有金鑰對的相關資訊。

aws ivs list-playback-key-pairs

輸出:

{ "keyPairs": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-key/abcd1234efgh", "name": "test-key-0", "tags": {} }, { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-key/ijkl5678mnop", "name": "test-key-1", "tags": {} } ] }

如需詳細資訊,請參閱《Amazon 互動式影片服務使用者指南》中的設定私有頻道

下列程式碼範例示範如何使用 list-playback-restriction-policies

AWS CLI

若要取得所有播放限制政策的摘要資訊

下列list-playback-restriction-policies範例列出您 AWS 帳戶的所有播放限制政策。

aws ivs list-playback-restriction-policies

輸出:

{ "playbackRestrictionPolicies": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "allowedCountries": [ "US", "MX" ], "allowedOrigins": [ "https://www.website1.com", "https://www.website2.com" ], "enableStrictOriginEnforcement": true, "name": "test-playback-restriction-policy", "tags": { "key1": "value1", "key2": "value2" } } ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

下列程式碼範例示範如何使用 list-recording-configurations

AWS CLI

列出在此帳戶中建立的所有 RecordingConfiguration 資源

下列list-recording-configurations範例會取得您帳戶中所有 RecordingConfiguration 資源的相關資訊。

aws ivs list-recording-configurations

輸出:

{ "recordingConfigurations": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABcdef34ghIJ", "name": "test-recording-config-1", "destinationConfiguration": { "s3": { "bucketName": "demo-recording-bucket-1" } }, "state": "ACTIVE", "tags": {} }, { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/CD12abcdGHIJ", "name": "test-recording-config-2", "destinationConfiguration": { "s3": { "bucketName": "demo-recording-bucket-2" } }, "state": "ACTIVE", "tags": {} } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南 中的錄製至 Amazon S3

下列程式碼範例示範如何使用 list-stream-keys

AWS CLI

若要取得串流金鑰清單

下列list-stream-keys範例會列出指定 ARN(Amazon Resource Name) 的所有串流金鑰。

aws ivs list-stream-keys \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh

輸出:

{ "streamKeys": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/abcdABCDefgh", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {} } ] }

FFor 如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 ListStreamKeys中的 。 AWS CLI

下列程式碼範例示範如何使用 list-stream-sessions

AWS CLI

取得目前 AWS 區域中指定頻道的目前和先前串流摘要

下列list-stream-sessions範例會報告指定頻道 ARN(Amazon Resource Name) 之串流的摘要資訊。

aws ivs list-stream-sessions \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ --max-results 25 \ --next-token ""

輸出:

{ "nextToken": "set-2", "streamSessions": [ { "startTime": 1641578182, "endTime": 1641579982, "hasErrorEvent": false, "streamId": "mystream" } ... ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

下列程式碼範例示範如何使用 list-streams

AWS CLI

若要取得即時串流及其狀態的清單

下列list-streams範例會列出您 AWS 帳戶的所有即時串流。

aws ivs list-streams

輸出:

{ "streams": [ { "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "state": "LIVE", "health": "HEALTHY", "streamId": "st-ABCDEfghij01234KLMN5678", "viewerCount": 1 } ] }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 ListStreams中的 。 AWS CLI

下列程式碼範例示範如何使用 list-tags-for-resource

AWS CLI

列出 AWS 資源的所有標籤 (例如:頻道、串流金鑰)

下列list-tags-for-resource範例會列出指定資源 ARN(Amazon Resource Name) 的所有標籤。

aws ivs list-tags-for-resource \ --resource-arn arn:aws:ivs:us-west-2:12345689012:channel/abcdABCDefgh

輸出:

{ "tags": { "key1": "value1", "key2": "value2" } }

如需詳細資訊,請參閱 Amazon Interactive Video Service API參考 中的標記

下列程式碼範例示範如何使用 put-metadata

AWS CLI

將中繼資料插入指定頻道的作用中串流

下列put-metadata範例會將指定的中繼資料插入指定頻道的串流。

aws ivs put-metadata \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ --metadata '{"my": "metadata"}'

此命令不會產生輸出。

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 PutMetadata中的 。 AWS CLI

下列程式碼範例示範如何使用 start-viewer-session-revocation

AWS CLI

撤銷指定多個頻道ARN和檢視器 ID 對的檢視器工作階段

下列start-viewer-session-revocation範例會開始撤銷與指定頻道ARN和檢視器 ID 相關聯的檢視器工作階段,直至並包含指定工作階段版本編號的程序。如果未提供版本,則預設為 0。

aws ivs batch-start-viewer-session-revocation \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ --viewer-id abcdefg \ --viewer-session-versions-less-than-or-equal-to 1234567890

此命令不會產生輸出。

如需詳細資訊,請參閱《Amazon 互動式影片服務使用者指南》中的設定私有頻道

下列程式碼範例示範如何使用 stop-stream

AWS CLI

停止指定的串流

下列stop-stream範例會停止指定頻道上的串流。

aws ivs stop-stream \ --channel-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh

此命令不會產生輸出。

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

  • 如需API詳細資訊,請參閱 命令參考 StopStream中的 。 AWS CLI

下列程式碼範例示範如何使用 tag-resource

AWS CLI

新增或更新 AWS 資源的標籤 (例如:頻道、串流金鑰)

下列tag-resource範例新增或更新指定資源的標籤 ARN(Amazon Resource Name)。

aws ivs tag-resource \ --resource-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ --tags "tagkey1=tagvalue1, tagkey2=tagvalue2"

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service API參考 中的標記

  • 如需API詳細資訊,請參閱 命令參考 TagResource中的 。 AWS CLI

下列程式碼範例示範如何使用 untag-resource

AWS CLI

移除 AWS 資源的標籤 (例如:頻道、串流金鑰)

下列untag-resource範例會移除指定資源 ARN(Amazon Resource Name) 的指定標籤。

aws ivs untag-resource \ --resource-arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ --tag-keys "tagkey1, tagkey2"

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service API參考 中的標記

  • 如需API詳細資訊,請參閱 命令參考 UntagResource中的 。 AWS CLI

下列程式碼範例示範如何使用 update-channel

AWS CLI

範例 1:更新頻道的組態資訊

下列update-channel範例會更新指定頻道的頻道組態,ARN以變更頻道名稱。這不會影響此頻道的持續串流;您必須停止並重新啟動串流,變更才會生效。

aws ivs update-channel \ --arn arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh \ --name "channel-1" \ --insecure-ingest

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "channel-1", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": true, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "authorized": false, "tags": {} }

如需詳細資訊,請參閱IVS低延遲使用者指南中的建立頻道

範例 2:更新頻道的組態以啟用錄製

下列update-channel範例會更新指定頻道的頻道組態ARN,以啟用錄製。這不會影響此頻道的持續串流;您必須停止並重新啟動串流,變更才會生效。

aws ivs update-channel \ --arn "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh" \ --no-insecure-ingest \ --recording-configuration-arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh"

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "test-channel-with-recording", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/ABCD12cdEFgh", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "BA1C2defGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "authorized": false, "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的記錄至 Amazon S3

範例 3:更新頻道的組態以停用錄製

下列update-channel範例會更新指定頻道的頻道組態ARN,以停用錄製。這不會影響此頻道的持續串流;您必須停止並重新啟動串流,變更才會生效。

aws ivs update-channel \ --arn "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh" \ --recording-configuration-arn ""

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "test-channel-with-recording", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2edfGHijkLMNo3PqQRstUvwxyzaBCDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "authorized": false, "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的記錄至 Amazon S3

範例 4:更新頻道的組態以啟用播放限制

下列update-channel範例會更新指定頻道的頻道組態,ARN以套用播放限制政策。這不會影響此頻道的持續串流;您必須停止並重新啟動串流,變更才會生效。

aws ivs update-channel \ --arn "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh" \ --no-insecure-ingest \ --playback-restriction-policy-arn "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ"

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "test-channel-with-playback-restriction-policy", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "recordingConfigurationArn": "", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2defGHijkLMNo3PqQRstUvwxyzaCBDEfghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "authorized": false, "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

範例 5:更新頻道的組態以停用播放限制

下列update-channel範例會更新指定頻道的頻道組態ARN,以停用播放限制。這不會影響此頻道的持續串流;您必須停止並重新啟動串流,變更才會生效。

aws ivs update-channel \ --arn "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh" \ --playback-restriction-policy-arn ""

輸出:

{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "name": "test-channel-with-playback-restriction-policy", "latencyMode": "LOW", "type": "STANDARD", "playbackRestrictionPolicyArn": "", "recordingConfigurationArn": "", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase": "AB1C2defGHijkLMNo3PqQRstUvwxyzaBCDeFghh4ijklMN5opqrStuVWxyzAbCDEfghIJ" }, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "preset": "", "authorized": false, "tags": {} } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器

  • 如需API詳細資訊,請參閱 命令參考 UpdateChannel中的 。 AWS CLI

下列程式碼範例示範如何使用 update-playback-restriction-policy

AWS CLI

更新播放限制政策

下列update-playback-restriction-policy範例會使用指定的政策更新播放限制政策ARN,以停用嚴格的原始伺服器強制執行。這不會影響關聯頻道的持續串流;您必須停止並重新啟動串流,變更才會生效。

aws ivs update-playback-restriction-policy \ --arn "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ" \ --no-enable-strict-origin-enforcement

輸出:

{ "playbackRestrictionPolicy": { "arn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ", "allowedCountries": [ "US", "MX" ], "allowedOrigins": [ "https://www.website1.com", "https://www.website2.com" ], "enableStrictOriginEnforcement": false, "name": "test-playback-restriction-policy", "tags": { "key1": "value1", "key2": "value2" } } }

如需詳細資訊,請參閱IVS低延遲使用者指南中的不需要的內容和檢視器