使用 的 Amazon IVS 即時串流範例 AWS CLI - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

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

使用 的 Amazon IVS 即時串流範例 AWS CLI

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

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

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

主題

動作

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

AWS CLI

若要建立合成編碼器組態

下列create-encoder-configuration範例會建立具有指定屬性的組合編碼器組態。

aws ivs-realtime create-encoder-configuration \ --name test-ec --video bitrate=3500000,framerate=30.0,height=1080,width=1920

輸出:

{ "encoderConfiguration": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef", "name": "test-ec", "tags": {}, "video": { "bitrate": 3500000, "framerate": 30, "height": 1080, "width": 1920 } } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

建立階段參與者權杖

下列create-participant-token範例會為指定的階段建立參與者 Toke。

aws ivs-realtime create-participant-token \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --user-id bob

輸出:

{ "participantToken": { "expirationTime": "2023-03-07T09:47:43+00:00", "participantId": "ABCDEfghij01234KLMN6789", "token": "abcd1234defg5678" } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

範例 1:建立階段

下列create-stage範例會為指定的使用者建立階段和階段參與者權杖。

aws ivs-realtime create-stage \ --name stage1 \ --participant-token-configurations userId=alice

輸出:

{ "participantTokens": [ { "participantId": "ABCDEfghij01234KLMN5678", "token": "a1b2c3d4567890ab", "userId": "alice" } ], "stage": { "activeSessionId": "st-a1b2c3d4e5f6g", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "endpoints": { "events": "wss://global.events.live-video.net", "whip": "https://1a2b3c4d5e6f.global-bm.whip.live-video.net" }, "name": "stage1", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

範例 2:建立階段並設定個別參與者記錄

下列create-stage範例會建立階段並設定個別參與者記錄。

aws ivs-realtime create-stage \ --name stage1 \ --auto-participant-recording-configuration '{"mediaTypes": ["AUDIO_VIDEO"],"storageConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:storage-configuration/abcdABCDefgh"}'

輸出:

{ "stage": { "activeSessionId": "st-a1b2c3d4e5f6g", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "autoParticipantRecordingConfiguration": { "mediaTypes": [ "AUDIO_VIDEO" ], "storageConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:storage-configuration/abcdABCDefgh", }, "endpoints": { "events": "wss://global.events.live-video.net", "whip": "https://1a2b3c4d5e6f.global-bm.whip.live-video.net" }, "name": "stage1", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

若要建立組合物儲存組態

下列create-storage-configuration範例會建立具有指定屬性的構圖儲存組態。

aws ivs-realtime create-storage-configuration \ --name "test-sc" --s3 "bucketName=test-bucket-name"

輸出:

{ "storageConfiguration": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/ABabCDcdEFef", "name": "test-sc", "s3": { "bucketName": "test-bucket-name" }, "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

刪除組成編碼器組態

以下內容會delete-encoder-configuration刪除指定 ARN (Amazon Resource Name) 指定的組成編碼器組態。

aws ivs-realtime delete-encoder-configuration \ --arn "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef"

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

若要刪除公有金鑰

下列 會delete-public-key刪除指定的公有金鑰。

aws ivs-realtime delete-public-key \ --arn arn:aws:ivs:us-west-2:123456789012:public-key/abcdABC1efg2

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon IVS 即時串流使用者指南中的分發參與者權杖

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

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

AWS CLI

若要刪除階段

下列delete-stage範例會刪除指定的階段。

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

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

若要刪除組合物儲存組態

以下內容會delete-storage-configuration刪除指定 ARN (Amazon Resource Name) 所指定的構圖儲存組態。

aws ivs-realtime delete-storage-configuration \ --arn "arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/ABabCDcdEFef"

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

下列程式碼範例示範如何使用 disconnect-participant

AWS CLI

若要中斷連接階段參與者

下列disconnect-participant範例會將指定的參與者與指定的階段中斷連線。

aws ivs-realtime disconnect-participant \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --participant-id ABCDEfghij01234KLMN5678

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

範例 1:使用預設配置設定取得構圖

下列get-composition範例取得指定 ARN (Amazon Resource Name) 的組成。

aws ivs-realtime get-composition \ --arn "arn:aws:ivs:ap-northeast-1:123456789012:composition/abcdABCDefgh"

輸出:

{ "composition": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:composition/abcdABCDefgh", "destinations": [ { "configuration": { "channel": { "channelArn": "arn:aws:ivs:ap-northeast-1:123456789012:channel/abcABCdefDEg", "encoderConfigurationArn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" }, "name": "" }, "id": "AabBCcdDEefF", "startTime": "2023-10-16T23:26:00+00:00", "state": "ACTIVE" }, { "configuration": { "name": "", "s3": { "encoderConfigurationArns": [ "arn:aws:ivs:arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" ], "recordingConfiguration": { "format": "HLS" }, "storageConfigurationArn": "arn:arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE" } }, "detail": { "s3": { "recordingPrefix": "aBcDeFgHhGfE/AbCdEfGhHgFe/GHFabcgefABC/composite" } }, "id": "GHFabcgefABC", "startTime": "2023-10-16T23:26:00+00:00", "state": "STARTING" } ], "layout": { "grid": { "featuredParticipantAttribute": "" "gridGap": 2, "omitStoppedVideo": false, "videoAspectRatio": "VIDEO", "videoFillMode": "" } }, "stageArn": "arn:aws:ivs:ap-northeast-1:123456789012:stage/defgABCDabcd", "startTime": "2023-10-16T23:24:00+00:00", "state": "ACTIVE", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的複合錄製 (即時串流)

範例 2:使用 PiP 配置取得 組成

下列get-composition範例會取得指定 ARN (Amazon Resource Name) 的組成,其使用 PiP 配置。

aws ivs-realtime get-composition \ --arn "arn:aws:ivs:ap-northeast-1:123456789012:composition/wxyzWXYZpqrs"

輸出:

{ "composition": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:composition/wxyzWXYZpqrs", "destinations": [ { "configuration": { "channel": { "channelArn": "arn:aws:ivs:ap-northeast-1:123456789012:channel/abcABCdefDEg", "encoderConfigurationArn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" }, "name": "" }, "id": "AabBCcdDEefF", "startTime": "2023-10-16T23:26:00+00:00", "state": "ACTIVE" }, { "configuration": { "name": "", "s3": { "encoderConfigurationArns": [ "arn:aws:ivs:arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" ], "recordingConfiguration": { "format": "HLS" }, "storageConfigurationArn": "arn:arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE" } }, "detail": { "s3": { "recordingPrefix": "aBcDeFgHhGfE/AbCdEfGhHgFe/GHFabcgefABC/composite" } }, "id": "GHFabcgefABC", "startTime": "2023-10-16T23:26:00+00:00", "state": "STARTING" } ], "layout": { "pip": { "featuredParticipantAttribute": "abcdefg", "gridGap": 0, "omitStoppedVideo": false, "pipBehavior": "STATIC", "pipOffset": 0, "pipParticipantAttribute": "", "pipPosition": "BOTTOM_RIGHT", "videoFillMode": "COVER" } }, "stageArn": "arn:aws:ivs:ap-northeast-1:123456789012:stage/defgABCDabcd", "startTime": "2023-10-16T23:24:00+00:00", "state": "ACTIVE", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的複合錄製 (即時串流)

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

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

AWS CLI

若要取得組合編碼器組態

下列get-encoder-configuration範例會取得指定 ARN (Amazon Resource Name) 指定的組成編碼器組態。

aws ivs-realtime get-encoder-configuration \ --arn "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/abcdABCDefgh"

輸出:

{ "encoderConfiguration": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/abcdABCDefgh", "name": "test-ec", "tags": {}, "video": { "bitrate": 3500000, "framerate": 30, "height": 1080, "width": 1920 } } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

若要取得階段參與者

下列get-participant範例取得指定參與者 ID 和指定階段 ARN (Amazon Resource Name) 中工作階段 ID 的階段參與者。

aws ivs-realtime get-participant \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --session-id st-a1b2c3d4e5f6g \ --participant-id abCDEf12GHIj

輸出:

{ "participant": { "browserName", "Google Chrome", "browserVersion", "116", "firstJoinTime": "2023-04-26T20:30:34+00:00", "ispName", "Comcast", "osName", "Microsoft Windows 10 Pro", "osVersion", "10.0.19044" "participantId": "abCDEf12GHIj", "published": true, "recordingS3BucketName": "bucket-name", "recordingS3Prefix": "abcdABCDefgh/st-a1b2c3d4e5f6g/abCDEf12GHIj/1234567890", "recordingState": "ACTIVE", "sdkVersion", "", "state": "CONNECTED", "userId": "", } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

若要取得用來簽署階段參與者權杖的現有公有金鑰

下列get-public-key範例會取得由提供的 ARN 指定的公有金鑰,用於簽署階段參與者權杖。

aws ivs-realtime get-public-key \ --arn arn:aws:ivs:us-west-2:123456789012:public-key/abcdABC1efg2

輸出:

{ "publicKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:public-key/abcdABC1efg2", "name": "", "publicKeyMaterial": "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEqVWUtqs6EktQMR1sCYmEzGvRwtaycI16\n9pmzcpiWu/uhNStGlteJ5odRfRwVkoQUMnSZXTCcbn9bBTTmiWo4mJcFOOAzsthH\n0UAb8NdD4tUE0At4a9hYP9IETEXAMPLE\n-----END PUBLIC KEY-----", "fingerprint": "12:a3:44:56:bc:7d:e8:9f:10:2g:34:hi:56:78:90:12", "tags": {} } }

如需詳細資訊,請參閱 Amazon IVS 即時串流使用者指南中的分發參與者權杖

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

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

AWS CLI

若要取得階段工作階段

下列get-stage-session範例取得指定階段 ARN (Amazon Resource Name) 之指定工作階段 ID 的階段工作階段。

aws ivs-realtime get-stage-session \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --session-id st-a1b2c3d4e5f6g

輸出:

{ "stageSession": { "endTime": "2023-04-26T20:36:29+00:00", "sessionId": "st-a1b2c3d4e5f6g", "startTime": "2023-04-26T20:30:29.602000+00:00" } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

若要取得階段的組態資訊

下列get-stage範例會取得指定階段 ARN (Amazon Resource Name) 的階段組態。

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

輸出:

{ "stage": { "activeSessionId": "st-a1b2c3d4e5f6g", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "autoParticipantRecordingConfiguration": { "mediaTypes": [ "AUDIO_VIDEO" ], "storageConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:storage-configuration/abcdABCDefgh", }, "endpoints": { "events": "wss://global.events.live-video.net", "whip": "https://1a2b3c4d5e6f.global-bm.whip.live-video.net" }, "name": "test", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

若要取得構圖儲存組態

下列get-storage-configuration範例會取得指定 ARN (Amazon Resource Name) 指定的構圖儲存組態。

aws ivs-realtime get-storage-configuration \ --name arn "arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/abcdABCDefgh"

輸出:

{ "storageConfiguration": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/abcdABCDefgh", "name": "test-sc", "s3": { "bucketName": "test-bucket-name" }, "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

匯入用於簽署階段參與者權杖的現有公有金鑰

下列import-public-key範例會從材料檔案匯入公有金鑰,用於簽署階段參與者權杖。

aws ivs-realtime import-public-key \ --public-key-material="`cat public.pem`"

輸出:

{ "publicKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:public-key/abcdABC1efg2", "name": "", "publicKeyMaterial": "-----BEGIN PUBLIC KEY-----\nMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEqVWUtqs6EktQMR1sCYmEzGvRwtaycI16\n9pmzcpiWu/uhNStGlteJ5odRfRwVkoQUMnSZXTCcbn9bBTTmiWo4mJcFOOAzsthH\n0UAb8NdD4tUE0At4a9hYP9IETEXAMPLE\n-----END PUBLIC KEY-----", "fingerprint": "12:a3:44:56:bc:7d:e8:9f:10:2g:34:hi:56:78:90:12", "tags": {} } }

如需詳細資訊,請參閱 Amazon IVS 即時串流使用者指南中的分發參與者權杖

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

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

AWS CLI

若要取得 組成清單

下列list-compositions列出處理 API 請求的 AWS 區域中,您 AWS 帳戶的所有組成。

aws ivs-realtime list-compositions

輸出:

{ "compositions": [ { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:composition/abcdABCDefgh", "destinations": [ { "id": "AabBCcdDEefF", "startTime": "2023-10-16T23:25:23+00:00", "state": "ACTIVE" } ], "stageArn": "arn:aws:ivs:ap-northeast-1:123456789012:stage/defgABCDabcd", "startTime": "2023-10-16T23:25:21+00:00", "state": "ACTIVE", "tags": {} }, { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:composition/ABcdabCDefgh", "destinations": [ { "endTime": "2023-10-16T23:25:00.786512+00:00", "id": "aABbcCDdeEFf", "startTime": "2023-10-16T23:24:01+00:00", "state": "STOPPED" }, { "endTime": "2023-10-16T23:25:00.786512+00:00", "id": "deEFfaABbcCD", "startTime": "2023-10-16T23:24:01+00:00", "state": "STOPPED" } ], "endTime": "2023-10-16T23:25:00+00:00", "stageArn": "arn:aws:ivs:ap-northeast-1:123456789012:stage/efghabcdABCD", "startTime": "2023-10-16T23:24:00+00:00", "state": "STOPPED", "tags": {} } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

若要列出組成編碼器組態

下列list-encoder-configurations列出處理 API 請求的 AWS 區域中,您 AWS 帳戶的所有組成編碼器組態。

aws ivs-realtime list-encoder-configurations

輸出:

{ "encoderConfigurations": [ { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/abcdABCDefgh", "name": "test-ec-1", "tags": {} }, { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABCefgEFGabc", "name": "test-ec-2", "tags": {} } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

若要取得階段參與者事件的清單

下列list-participant-events範例會列出指定參與者 ID 的所有參與者事件,以及指定階段 ARN (Amazon Resource Name) 的工作階段 ID。

aws ivs-realtime list-participant-events \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --session-id st-a1b2c3d4e5f6g \ --participant-id abCDEf12GHIj

輸出:

{ "events": [ { "eventTime": "2023-04-26T20:36:28+00:00", "name": "LEFT", "participantId": "abCDEf12GHIj" }, { "eventTime": "2023-04-26T20:36:28+00:00", "name": "PUBLISH_STOPPED", "participantId": "abCDEf12GHIj" }, { "eventTime": "2023-04-26T20:30:34+00:00", "name": "JOINED", "participantId": "abCDEf12GHIj" }, { "eventTime": "2023-04-26T20:30:34+00:00", "name": "PUBLISH_STARTED", "participantId": "abCDEf12GHIj" } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

AWS CLI

若要取得階段參與者的清單

下列list-participants範例列出指定階段 ARN (Amazon Resource Name) 之指定工作階段 ID 的所有參與者。

aws ivs-realtime list-participants \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --session-id st-a1b2c3d4e5f6g

輸出:

{ "participants": [ { "firstJoinTime": "2023-04-26T20:30:34+00:00", "participantId": "abCDEf12GHIj" "published": true, "recordingState": "STOPPED", "state": "DISCONNECTED", "userId": "" } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

列出可用於簽署階段參與者權杖的現有公有金鑰

下列list-public-keys範例列出處理 API 請求的 AWS 區域中,可用於簽署階段參與者權杖的所有公有金鑰。

aws ivs-realtime list-public-keys

輸出:

{ "publicKeys": [ { "arn": "arn:aws:ivs:us-west-2:123456789012:public-key/abcdABC1efg2", "name": "", "tags": {} }, { "arn": "arn:aws:ivs:us-west-2:123456789012:public-key/3bcdABCDefg4", "name": "", "tags": {} } ] }

如需詳細資訊,請參閱 Amazon IVS 即時串流使用者指南中的分發參與者權杖

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

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

AWS CLI

若要取得階段工作階段清單

下列list-stage-sessions範例會列出指定階段 ARN (Amazon Resource Name) 的所有工作階段。

aws ivs-realtime list-stage-sessions \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh

輸出:

{ "stageSessions": [ { "endTime": "2023-04-26T20:36:29+00:00", "sessionId": "st-a1b2c3d4e5f6g", "startTime": "2023-04-26T20:30:29.602000+00:00" } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

取得所有階段的摘要資訊

下列list-stages範例列出處理 API 請求的 AWS 區域中,您 AWS 帳戶的所有階段。

aws ivs-realtime list-stages

輸出:

{ "stages": [ { "activeSessionId": "st-a1b2c3d4e5f6g", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "name": "stage1", "tags": {} }, { "activeSessionId": "st-a123bcd456efg", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcd1234ABCD", "name": "stage2", "tags": {} }, { "activeSessionId": "st-abcDEF1234ghi", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/ABCD1234efgh", "name": "stage3", "tags": {} } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

列出構圖儲存組態

下列list-storage-configurations列出處理 API 請求 AWS 的區域中,您 AWS 帳戶的所有組成儲存組態。

aws ivs-realtime list-storage-configurations

輸出:

{ "storageConfigurations": [ { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/abcdABCDefgh", "name": "test-sc-1", "s3": { "bucketName": "test-bucket-1-name" }, "tags": {} }, { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/ABCefgEFGabc", "name": "test-sc-2", "s3": { "bucketName": "test-bucket-2-name" }, "tags": {} } ] }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

下列程式碼範例示範如何使用 start-composition

AWS CLI

範例 1:使用預設配置設定啟動構圖

下列start-composition範例會啟動要串流至指定位置之指定階段的組成。

aws ivs-realtime start-composition \ --stage-arn arn:aws:ivs:ap-northeast-1:123456789012:stage/defgABCDabcd \ --destinations '[{"channel": {"channelArn": "arn:aws:ivs:ap-northeast-1:123456789012:channel/abcABCdefDEg", \ "encoderConfigurationArn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef"}}, \ {"s3":{"encoderConfigurationArns":["arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef"], \ "storageConfigurationArn":"arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE"}}]'

輸出:

{ "composition": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:composition/abcdABCDefgh", "destinations": [ { "configuration": { "channel": { "channelArn": "arn:aws:ivs:ap-northeast-1:123456789012:channel/abcABCdefDEg", "encoderConfigurationArn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" }, "name": "" }, "id": "AabBCcdDEefF", "state": "STARTING" }, { "configuration": { "name": "", "s3": { "encoderConfigurationArns": [ "arn:aws:ivs:arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" ], "recordingConfiguration": { "format": "HLS" }, "storageConfigurationArn": "arn:arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE" } }, "detail": { "s3": { "recordingPrefix": "aBcDeFgHhGfE/AbCdEfGhHgFe/GHFabcgefABC/composite" } }, "id": "GHFabcgefABC", "state": "STARTING" } ], "layout": { "grid": { "featuredParticipantAttribute": "" "gridGap": 2, "omitStoppedVideo": false, "videoAspectRatio": "VIDEO", "videoFillMode": "" } }, "stageArn": "arn:aws:ivs:ap-northeast-1:123456789012:stage/defgABCDabcd", "startTime": "2023-10-16T23:24:00+00:00", "state": "STARTING", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的複合錄製 (即時串流)

範例 2:使用 PiP 配置啟動構圖

下列start-composition範例會啟動使用 PiP 配置將指定階段串流至指定位置的構成。

aws ivs-realtime start-composition \ --stage-arn arn:aws:ivs:ap-northeast-1:123456789012:stage/defgABCDabcd \ --destinations '[{"channel": {"channelArn": "arn:aws:ivs:ap-northeast-1:123456789012:channel/abcABCdefDEg", \ "encoderConfigurationArn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef"}}, \ {"s3":{"encoderConfigurationArns":["arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef"], \ "storageConfigurationArn":"arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE"}}]' \ --layout pip='{featuredParticipantAttribute="abcdefg"}'

輸出:

{ "composition": { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:composition/wxyzWXYZpqrs", "destinations": [ { "configuration": { "channel": { "channelArn": "arn:aws:ivs:ap-northeast-1:123456789012:channel/abcABCdefDEg", "encoderConfigurationArn": "arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" }, "name": "" }, "id": "AabBCcdDEefF", "state": "STARTING" }, { "configuration": { "name": "", "s3": { "encoderConfigurationArns": [ "arn:aws:ivs:arn:aws:ivs:ap-northeast-1:123456789012:encoder-configuration/ABabCDcdEFef" ], "recordingConfiguration": { "format": "HLS" }, "storageConfigurationArn": "arn:arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE" } }, "detail": { "s3": { "recordingPrefix": "aBcDeFgHhGfE/AbCdEfGhHgFe/GHFabcgefABC/composite" } }, "id": "GHFabcgefABC", "state": "STARTING" } ], "layout": { "pip": { "featuredParticipantAttribute": "abcdefg", "gridGap": 0, "omitStoppedVideo": false, "pipBehavior": "STATIC", "pipOffset": 0, "pipParticipantAttribute": "", "pipPosition": "BOTTOM_RIGHT", "videoFillMode": "COVER" } }, "stageArn": "arn:aws:ivs:ap-northeast-1:123456789012:stage/defgABCDabcd", "startTime": "2023-10-16T23:24:00+00:00", "state": "STARTING", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的複合錄製 (即時串流)

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

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

AWS CLI

停止撰寫

下列 會stop-composition停止指定 ARN (Amazon Resource Name) 指定的組成。

aws ivs-realtime stop-composition \ --arn "arn:aws:ivs:ap-northeast-1:123456789012:composition/abcdABCDefgh"

此命令不會產生輸出。

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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

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

AWS CLI

更新階段的組態

下列update-stage範例會更新指定階段 ARN 的階段,以更新階段名稱並設定個別參與者記錄。

aws ivs-realtime update-stage \ --arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --auto-participant-recording-configuration '{"mediaTypes": ["AUDIO_VIDEO"],"storageConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:storage-configuration/abcdABCDefgh"}' \ --name stage1a

輸出:

{ "stage": { "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "autoParticipantRecordingConfiguration": { "mediaTypes": [ "AUDIO_VIDEO" ], "storageConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:storage-configuration/abcdABCDefgh", }, "endpoints": { "events": "wss://global.events.live-video.net", "whip": "https://1a2b3c4d5e6f.global-bm.whip.live-video.net" }, "name": "stage1a", "tags": {} } }

如需詳細資訊,請參閱 Amazon Interactive Video Service 使用者指南中的在 Amazon IVS Stream 上啟用多個主機

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