使用 Amazon IVS 实时直播示例 AWS CLI - AWS SDK 代码示例

文档 AWS SDK 示例 GitHub 存储库中还有更多 S AWS DK 示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用 Amazon IVS 实时直播示例 AWS CLI

以下代码示例向您展示如何使用 AWS Command Line Interface 与 Amazon IVS 实时流媒体配合使用来执行操作和实现常见场景。

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以从中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示了如何使用 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-ingest-configuration

AWS CLI

创建摄取配置

以下 create-ingest-configuration 示例使用 RTMPS 协议创建摄取配置。

aws ivs-realtime create-ingest-configuration \ --name ingest1 \ --ingest-protocol rtmps

输出:

{ "ingestConfiguration": { "name": "ingest1", "arn": "arn:aws:ivs:us-west-2:123456789012:ingest-configuration/AbCdEfGh1234", "ingestProtocol": "RTMPS", "streamKey": "rt_123456789012_us-west-2_AbCdEfGh1234_abcd1234efgh5678ijkl9012MNOP34", "stageArn": "", "participantId": "xyZ654abC321", "state": "INACTIVE", "userId": "", "tags": {} } }

有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的 IVS 流摄取 | 实时直播功能

以下代码示例演示了如何使用 create-participant-token

AWS CLI

创建阶段参与者令牌

以下 create-participant-token 示例为指定阶段创建参与者令牌。

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", "autoParticipantRecordingConfiguration": { "storageConfigurationArn": "", "mediaTypes": [ "AUDIO_VIDEO" ], "thumbnailConfiguration": { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ], "recordingMode": "DISABLED" }, "recordingReconnectWindowSeconds": 0, "hlsConfiguration": { "targetSegmentDurationSeconds": 6 }, "recordParticipantReplicas": true }, "endpoints": { "events": "wss://global.events.live-video.net", "rtmp": "rtmp://9x0y8z7s6t5u.global-contribute-staging.live-video.net/app/", "rtmps": "rtmps://9x0y8z7s6t5u.global-contribute-staging.live-video.net:443/app/", "whip": "https://9x0y8z7s6t5u.global-bm.whip.live-video.net" }, "name": "stage1", "tags": {} } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 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", "recordingReconnectWindowSeconds": 100, \ "hlsConfiguration": {"targetSegmentDurationSeconds": 5}}'

输出:

{ "stage": { "activeSessionId": "st-a1b2c3d4e5f6g", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "autoParticipantRecordingConfiguration": { "storageConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:storage-configuration/abcdABCDefgh" "mediaTypes": [ "AUDIO_VIDEO" ], "thumbnailConfiguration": { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ], "recordingMode": "DISABLED" }, "recordingReconnectWindowSeconds": 100, "hlsConfiguration": { "targetSegmentDurationSeconds": 5 }, "recordParticipantReplicas": true }, "endpoints": { "events": "wss://global.events.live-video.net", "rtmp": "rtmp://9x0y8z7s6t5u.global-contribute-staging.live-video.net/app/", "rtmps": "rtmps://9x0y8z7s6t5u.global-contribute-staging.live-video.net:443/app/", "whip": "https://9x0y8z7s6t5u.global-bm.whip.live-video.net" }, "name": "stage1", "tags": {} } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 3:创建阶段并配置启用缩略图录制的单个参与者录制

以下 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", \ "thumbnailConfiguration": {"recordingMode": "INTERVAL","storage": ["SEQUENTIAL"],"targetIntervalSeconds": 60}}'

输出:

{ "stage": { "activeSessionId": "st-a1b2c3d4e5f6g", "arn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "autoParticipantRecordingConfiguration": { "storageConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:storage-configuration/abcdABCDefgh", "mediaTypes": [ "AUDIO_VIDEO" ], "thumbnailConfiguration": { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ], "recordingMode": "INTERVAL" }, "recordingReconnectWindowSeconds": 0, "hlsConfiguration": { "targetSegmentDurationSeconds": 6 }, "recordParticipantReplicas": true }, "endpoints": { "events": "wss://global.events.live-video.net", "rtmp": "rtmp://9x0y8z7s6t5u.global-contribute-staging.live-video.net/app/", "rtmps": "rtmps://9x0y8z7s6t5u.global-contribute-staging.live-video.net:443/app/", "whip": "https://9x0y8z7s6t5u.global-bm.whip.live-video.net" }, "name": "stage1", "tags": {} } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

  • 有关 API 的详细信息,请参阅AWS CLI 命令参考CreateStage中的。

以下代码示例演示了如何使用 create-storage-configuration

AWS CLI

创建合成存储配置

以下 create-storage-configuration 示例使用指定属性创建一个合成存储配置。

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

输出:

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

有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的在 Amazon IVS Stream 中启用多个主播

以下代码示例演示了如何使用 delete-encoder-configuration

AWS CLI

删除合成编码器配置

以下 delete-encoder-configuration 命令删除由给定 ARN(Amazon 资源名称)指定的合成编码器配置。

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-ingest-configuration

AWS CLI

示例 1:删除非活动摄取配置

以下 delete-ingest-configuration 示例删除指定摄取配置 ARN(Amazon 资源名称)的非活动摄取配置。

aws ivs-realtime delete-ingest-configuration \ --arn arn:aws:ivs:us-west-2:123456789012:ingest-configuration/AbCdEfGh1234

此命令不生成任何输出。

有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的 IVS 流摄取 | 实时直播功能

示例 2:强制删除活动摄取配置

以下 delete-ingest-configuration 示例强制删除指定摄取配置 ARN(Amazon 资源名称)的活动摄取配置。

aws ivs-realtime delete-ingest-configuration \ --arn arn:aws:ivs:us-west-2:123456789012:ingest-configuration/AbCdEfGh1234 \ --force

此命令不生成任何输出。

有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的 IVS 流摄取 | 实时直播功能

以下代码示例演示了如何使用 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 资源名称)指定的合成存储配置。

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 资源名称)的合成。

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", "hlsConfiguration": { "targetSegmentDurationSeconds": 2 } }, "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 IVS Real-Time Streaming User Guide》中的 IVS 合成录制 | 实时直播功能

示例 2:获取采用 PiP 布局的合成

以下 get-composition 示例获取采用 PiP 布局的指定 ARN(Amazon 资源名称)的合成。

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", "hlsConfiguration": { "targetSegmentDurationSeconds": 2 } }, "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 IVS Real-Time Streaming User Guide》中的 IVS 合成录制 | 实时直播功能

示例 3:在启用缩略图录制的情况下获取合成

以下 get-composition 示例获取指定的 ARN(Amazon 资源名称)的合成,该 ARN 已使用默认设置启用缩略图录制。

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", "hlsConfiguration": { "targetSegmentDurationSeconds": 2 } }, "storageConfigurationArn": "arn:arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE", "thumbnailConfigurations": [ { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ], } ] } }, "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 IVS Real-Time Streaming User Guide》中的 IVS 合成录制 | 实时直播功能

  • 有关 API 的详细信息,请参阅AWS CLI 命令参考GetComposition中的。

以下代码示例演示了如何使用 get-encoder-configuration

AWS CLI

获取合成编码器配置

以下 get-encoder-configuration 示例获取由给定 ARN(Amazon 资源名称)指定的合成编码器配置。

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-ingest-configuration

AWS CLI

获取摄取配置信息

以下 get-ingest-configuration 示例获取指定摄取配置 ARN(Amazon 资源名称)的摄取配置。

aws ivs-realtime get-ingest-configuration \ --arn arn:aws:ivs:us-west-2:123456789012:ingest-configuration/AbCdEfGh1234

输出:

{ "ingestConfiguration": { "name": "ingest1", "arn": "arn:aws:ivs:us-west-2:123456789012:ingest-configuration/AbCdEfGh1234", "ingestProtocol": "RTMPS", "streamKey": "rt_123456789012_us-west-2_AbCdEfGh1234_abcd1234efgh5678ijkl9012MNOP34", "stageArn": "", "participantId": "xyZ654abC321", "state": "INACTIVE", "userId": "", "tags": {} } }

有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的 IVS 流摄取 | 实时直播功能

以下代码示例演示了如何使用 get-participant

AWS CLI

示例 1:获取舞台参与者

以下 get-participant 示例获取指定阶段 ARN(Amazon 资源名称)中指定参与者 ID 和会话 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 IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 2:获取已复制到另一个阶段的舞台参与者

以下get-participant示例获取指定阶段 ARN(Amazon 资源名称)中指定参与者 ID 和会话 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", "replicationState": "ACTIVE", "replicationType": "SOURCE", "sdkVersion": "", "state": "CONNECTED", "userId": "" } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 3:获取已从另一个阶段复制的舞台参与者

以下get-participant示例获取指定阶段 ARN(Amazon 资源名称)中指定参与者 ID 和会话 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", "replicationState": "ACTIVE", "replicationType": "REPLICA", "sdkVersion": "", "state": "CONNECTED", "userId": "" } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

  • 有关 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 资源名称)的指定会话 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 资源名称)的阶段配置。

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": { "storageConfigurationArn": "", "mediaTypes": [ "AUDIO_VIDEO" ], "thumbnailConfiguration": { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ], "recordingMode": "DISABLED" }, "recordingReconnectWindowSeconds": 0, "hlsConfiguration": { "targetSegmentDurationSeconds": 6 }, "recordParticipantReplicas": true }, "endpoints": { "events": "wss://global.events.live-video.net", "rtmp": "rtmp://9x0y8z7s6t5u.global-contribute-staging.live-video.net/app/", "rtmps": "rtmps://9x0y8z7s6t5u.global-contribute-staging.live-video.net:443/app/", "whip": "https://9x0y8z7s6t5u.global-bm.whip.live-video.net" }, "name": "test", "tags": {} } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

  • 有关 API 的详细信息,请参阅AWS CLI 命令参考GetStage中的。

以下代码示例演示了如何使用 get-storage-configuration

AWS CLI

获取合成存储配置

以下 get-storage-configuration 示例获取由给定 ARN(Amazon 资源名称)指定的合成存储配置。

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": "amzn-s3-demo-bucket" }, "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列出了您 AWS 账户在处理 API 请求的 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-ingest-configurations

AWS CLI

获取有关所有摄取配置的摘要信息

以下list-ingest-configurations示例列出了处理 API 请求的 AWS 区域中您的 AWS 账户的所有采集配置。

aws ivs-realtime list-ingest-configurations

输出:

{ "ingestConfigurations": [ { "name": "", "arn": "arn:aws:ivs:us-west-2:123456789012:ingest-configuration/XYZuvwSt4567", "ingestProtocol": "RTMPS", "stageArn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "participnatId": "abC789Xyz456", "state": "INACTIVE" "userId": "", } ] }

有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的 IVS 流摄取 | 实时直播功能

以下代码示例演示了如何使用 list-participant-events

AWS CLI

示例 1:获取舞台参与者活动列表

以下 list-participant-events 示例列出指定阶段 ARN(Amazon 资源名称)的指定参与者 ID 和会话 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 IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 2:获取舞台参与者事件列表,包括参与者复制停止和启动

以下list-participant-events示例列出了指定阶段 ARN(Amazon 资源名称)的指定会话 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": "2025-04-26T20:36:28+00:00", "name": "LEFT", "participantId": "abCDEf12GHIj" }, { "eventTime": "2025-04-26T20:36:28+00:00", "name": "PUBLISH_STOPPED", "participantId": "abCDEf12GHIj" }, { "eventTime": "2025-04-26T20:30:34+00:00", "name": "JOINED", "participantId": "abCDEf12GHIj" }, { "eventTime": "2025-04-26T20:30:34+00:00", "name": "PUBLISH_STARTED", "participantId": "abCDEf12GHIj" }, { "name": "REPLICATION_STARTED", "participantId": "abCDEf12GHIj", "eventTime": "2025-04-26T20:30:34+00:00", "destinationStageArn": "arn:aws:ivs:us-west-2:12345678901:stage/ABCDabcdefgh", "destinationSessionId": "st-b1c2d3e4f5g6a" }, { "name": "REPLICATION_STOPPED", "participantId": "abCDEf12GHIj", "eventTime": "2025-04-26T20:32:34+00:00", "destinationStageArn": "arn:aws:ivs:us-west-2:12345678901:stage/ABCDabcdefgh", "destinationSessionId": "st-b1c2d3e4f5g6a" } ] }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

以下代码示例演示了如何使用 list-participant-replicas

AWS CLI

获取舞台参与者副本列表

以下list-participant-replicas示例列出了从指定源阶段 ARN(Amazon 资源名称)复制到另一个阶段的所有阶段参与者。

aws ivs-realtime list-participant-replicas \ --source-stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --participant-id abCDEf12GHIj

输出:

{ "replicas": [ { "sourceStageArn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "participantId": "abCDEf12GHIj", "sourceSessionId": "st-a1b2c3d4e5f6g", "destinationStageArn": "arn:aws:ivs:us-west-2:012345678901:stage/ABCDabcdefgh", "destinationSessionId": "st-b1c2d3e4f5g6a", "replicationState": "ACTIVE" } ] }

有关更多信息,请参阅 Amazon IVS 实时直播用户指南中的 IVS 参与者复制

以下代码示例演示了如何使用 list-participants

AWS CLI

示例 1:获取舞台参与者名单

以下 list-participants 示例列出指定阶段 ARN(Amazon 资源名称)的指定会话 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 IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 2:当参与者被复制到另一个阶段时,获取阶段参与者列表

以下list-participants示例列出了指定阶段 ARN(Amazon 资源名称)的指定会话 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": "", "replicationState": "ACTIVE", "replicationType": "SOURCE", "sourceStageArn": "", "sourceSessionId": "" } ] }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 3:获取阶段参与者列表,当参与者已从另一个阶段复制时

以下list-participants示例列出了指定阶段 ARN(Amazon 资源名称)的指定会话 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": "", "replicationState": "ACTIVE", "replicationType": "REPLICA", "sourceStageArn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "sourceSessionId": "st-a1b2c3d4e5f6g" } ] }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

  • 有关 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 资源名称)的所有会话。

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示例列出了您的 AWS 账户在处理 API 请求的 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": "amzn-s3-demo-bucket-1" }, "tags": {} }, { "arn": "arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/ABCefgEFGabc", "name": "test-sc-2", "s3": { "bucketName": "amzn-s3-demo-bucket-2" }, "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"], \ "recordingConfiguration": {"hlsConfiguration": {"targetSegmentDurationSeconds": 5}}, \ "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", "hlsConfiguration": { "targetSegmentDurationSeconds": 5 } }, "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 IVS Real-Time Streaming User Guide》中的 IVS 合成录制 | 实时直播功能

示例 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", "hlsConfiguration": { "targetSegmentDurationSeconds": 2 } }, "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 IVS Real-Time Streaming User Guide》中的 IVS 合成录制 | 实时直播功能

示例 3:在启用缩略图录制的情况下开始合成

以下 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", \ "thumbnailConfigurations": [{"storage": ["SEQUENTIAL"],"targetIntervalSeconds": 60}]}}]'

输出:

{ "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", "hlsConfiguration": { "targetSegmentDurationSeconds": 2 } }, "storageConfigurationArn": "arn:arn:aws:ivs:ap-northeast-1:123456789012:storage-configuration/FefABabCDcdE", "thumbnailConfigurations": [ { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ] } ] } }, "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 IVS Real-Time Streaming User Guide》中的 IVS 合成录制 | 实时直播功能

  • 有关 API 的详细信息,请参阅AWS CLI 命令参考StartComposition中的。

以下代码示例演示了如何使用 start-participant-replication

AWS CLI

开始将参与者从一个阶段复制到另一个阶段

以下start-participant-replication示例将参与者从源阶段复制到目标阶段,每个阶段由其 ARN(Amazon 资源名称)指定。

aws ivs-realtime start-participant-replication \ --source-stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --destination-stage-arn arn:aws:ivs:us-west-2:234567890123:stage/bcdABCDefghi \ --participant-id abCDEf12GHIj

输出:

{ "accessControlAllowOrigin": "*", "accessControlExposeHeaders": "Access-Control-Allow-Origin,Access-Control-Expose-Headers,Cache-Control,Content-Length, \ Content-Security-Policy,Content-Type,date,Strict-Transport-Security,x-amz-apigw-id,x-amzn-errormessage,x-amzn-errortype, \ x-amzn-requestid,x-amzn-trace-id,X-Content-Type-Options,X-Frame-Options", "cacheControl": "no-store, no-cache", "contentSecurityPolicy": "default-src 'self'; upgrade-insecure-requests;", "strictTransportSecurity": "max-age:47304000; includeSubDomains", "xContentTypeOptions": "nosniff", "xFrameOptions": "DENY" }

有关更多信息,请参阅 Amazon IVS 实时直播用户指南中的 IVS 参与者复制

以下代码示例演示了如何使用 stop-composition

AWS CLI

停止合成

以下 stop-composition 命令停止由给定 ARN(Amazon 资源名称)指定的合成。

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中的。

以下代码示例演示了如何使用 stop-participant-replication

AWS CLI

停止将参与者从一个阶段复制到另一个阶段

以下stop-participant-replication示例停止将参与者从源阶段复制到目标阶段,每个阶段都由其 ARN(Amazon 资源名称)指定。

aws ivs-realtime stop-participant-replication \ --source-stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh \ --destination-stage-arn arn:aws:ivs:us-west-2:234567890123:stage/bcdABCDefghi \ --participant-id abCDEf12GHIj

输出:

{ "accessControlAllowOrigin": "*", "accessControlExposeHeaders": "Access-Control-Allow-Origin,Access-Control-Expose-Headers,Cache-Control,Content-Length, \ Content-Security-Policy,Content-Type,date,Strict-Transport-Security,x-amz-apigw-id,x-amzn-errormessage,x-amzn-errortype, \ x-amzn-requestid,x-amzn-trace-id,X-Content-Type-Options,X-Frame-Options", "cacheControl": "no-store, no-cache", "contentSecurityPolicy": "default-src 'self'; upgrade-insecure-requests;", "strictTransportSecurity": "max-age:47304000; includeSubDomains", "xContentTypeOptions": "nosniff", "xFrameOptions": "DENY" }

有关更多信息,请参阅 Amazon IVS 实时直播用户指南中的 IVS 参与者复制

以下代码示例演示了如何使用 update-ingest-configuration

AWS CLI

更新摄取配置

以下 update-inegst-configuration 示例更新摄取配置以将其附加到阶段。

aws ivs-realtime update-ingest-configuration \ --arn arn:aws:ivs:us-west-2:123456789012:ingest-configuration/AbCdEfGh1234 \ --stage-arn arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh

输出:

{ "ingestConfiguration": { "name": "ingest1", "arn": "arn:aws:ivs:us-west-2:123456789012:ingest-configuration/AbCdEfGh1234", "ingestProtocol": "RTMPS", "streamKey": "rt_123456789012_us-west-2_AbCdEfGh1234_abcd1234efgh5678ijkl9012MNOP34", "stageArn": "arn:aws:ivs:us-west-2:123456789012:stage/abcdABCDefgh", "participantId": "xyZ654abC321", "state": "INACTIVE", "userId": "", "tags": {} } }

有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的 IVS 流摄取 | 实时直播功能

以下代码示例演示了如何使用 update-stage

AWS CLI

示例 1:更新舞台的配置

以下 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", "recordingReconnectWindowSeconds": 100, \ "thumbnailConfiguration": {"recordingMode": "INTERVAL","storage": ["SEQUENTIAL"],"targetIntervalSeconds": 60}} \ "hlsConfiguration": {"targetSegmentDurationSeconds": 5}}' \ --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", "thumbnailConfiguration": { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ], "recordingMode": "INTERVAL" }, "recordingReconnectWindowSeconds": 100, "hlsConfiguration": { "targetSegmentDurationSeconds": 5 }, "recordParticipantReplicas": true }, "endpoints": { "events": "wss://global.events.live-video.net", "rtmp": "rtmp://9x0y8z7s6t5u.global-contribute-staging.live-video.net/app/", "rtmps": "rtmps://9x0y8z7s6t5u.global-contribute-staging.live-video.net:443/app/", "whip": "https://1a2b3c4d5e6f.global-bm.whip.live-video.net" }, "name": "stage1a", "tags": {} } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

示例 2:更新舞台配置,包括禁用参与者副本录制

以下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", "recordingReconnectWindowSeconds": 100, \ "thumbnailConfiguration": {"recordingMode": "INTERVAL","storage": ["SEQUENTIAL"],"targetIntervalSeconds": 60}, "recordParticipantReplicas":false} \ "hlsConfiguration": {"targetSegmentDurationSeconds": 5}}' \ --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", "thumbnailConfiguration": { "targetIntervalSeconds": 60, "storage": [ "SEQUENTIAL" ], "recordingMode": "INTERVAL" }, "recordingReconnectWindowSeconds": 100, "hlsConfiguration": { "targetSegmentDurationSeconds": 5 }, "recordParticipantReplicas": false }, "endpoints": { "events": "wss://global.events.live-video.net", "rtmp": "rtmp://9x0y8z7s6t5u.global-contribute-staging.live-video.net/app/", "rtmps": "rtmps://9x0y8z7s6t5u.global-contribute-staging.live-video.net:443/app/", "whip": "https://1a2b3c4d5e6f.global-bm.whip.live-video.net" }, "name": "stage1a", "tags": {} } }

有关更多信息,请参阅《Amazon IVS Low-Latency Streaming User Guide》中的在 Amazon IVS 流中启用多台主机

  • 有关 API 的详细信息,请参阅AWS CLI 命令参考UpdateStage中的。