创建 IVS 通道的 CLI 说明
使用 Amazon CLI 创建通道是一个高级选项,需要先在计算机上下载并配置 CLI。有关详细信息,请参阅 Amazon 命令行界面用户指南。
执行以下两个步骤之一,具体取决于您是否在启用录制的情况下创建通道。
创建通道但不录制
-
运行
create-channel
命令并传入一个可选名称:aws ivs create-channel --name test-channel
-
此时将返回一个新通道:
{ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "authorized": false, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "latencyMode": "LOW", "name": "channel-live", "playbackRestrictionPolicyArn": "arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/abcdABCDefgh", "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "recordingConfigurationArn": "none", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase: "ZU5A3yrjGAkghUNDr0c5NXBhsPrjlmtcKMNBluh7oImwJQ3ijeyClvMKxlpPcGAMziICJ", }, "tags": {}, "type": "STANDARD" }, "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/g1H2I3j4k5L6", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {}, "value": "sk_us-west-2_abcdABCDefgh_567890abcdef" } }
-
重要提示:记下
ingestEndpoint
、streamKey value
和playbackUrl
。您将使用它们来设置流传输和播放。
使用录制创建通道
先决条件:在开始此过程之前,请创建一个 Amazon S3 存储桶,并记下其 ARN。请参阅 Amazon S3 入门。S3 存储桶必须位于您要创建录制配置的同一区域;请参阅以下第 1 步中的已知问题。
然后执行以下步骤以创建通道:
-
运行
create-recording-configuration
命令并传入现有 Amazon S3 存储桶的 ARN:aws ivs create-recording-configuration --name configuration-1 --destination-configuration s3={bucketName=test-bucket}
您还可以传递
thumbnail-configuration
参数以手动设置缩略图录制模式和缩略图间隔:aws ivs create-recording-configuration --name configuration-1 --destination-configuration s3={bucketName=s3_bucket_name} --thumbnail-configuration recordingMode="INTERVAL",targetIntervalSeconds=60
(可选)传递
recording-reconnect-window-seconds
参数以启用片段化的流功能:aws ivs create-recording-configuration --name configuration-1 --destination-configuration s3={bucketName=test-bucket} --recording-reconnect-window-seconds 60
已知问题:在 us-east-1 区域中,如果您使用 Amazon CLI 创建录制配置,则即使 S3 存储桶位于不同区域,也会返回成功。在本案例中,录制配置的
state
为CREATE_FAILED
(而不是ACTIVE
)。(在其他区域中,如果存储桶位于不同区域,CLI 会正确返回失败结果。)解决办法:确保您的 S3 存储桶与录制配置位于同一区域。如果您在与 S3 存储桶不同的区域创建了录制配置,请删除该录制配置,并从正确的区域创建一个带有 S3 存储桶的新配置。
-
这将返回带有唯一 ARN 的新录制配置。录制配置的状态为
CREATING
,表示当前正在创建。{ "recordingConfiguration": { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te", "name": "configuration-1", "destinationConfiguration": { "s3": { "bucketName": "s3_bucket_name" } }, "recordingReconnectWindowSeconds": 60, "state": "CREATING", "tags": {}, "thumbnailConfiguration": { "recordingMode": "INTERVAL", "targetIntervalSeconds": 60 } } }
-
创建录制配置通常在数秒钟内完成,但最多可能需要 20 秒钟。要检查是否已创建录制配置,请运行
get-recording-configuration
命令:aws ivs get-recording-configuration --arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te"
-
这将返回一个响应,指示录制配置已创建(
state
是ACTIVE
):{ "recordingConfiguration": { "arn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te", "name": "configuration-1", "destinationConfiguration": { "s3": { "bucketName": "s3_bucket_name" } }, "recordingReconnectWindowSeconds": 60, "state": "ACTIVE", "tags": {}, "thumbnailConfiguration": { "recordingMode": "INTERVAL", "targetIntervalSeconds": 60 } } }
-
要创建通道并启用通道录制功能,请运行
create-channel
命令并传入录制配置 ARN:aws ivs create-channel --name channel-live --recording-configuration-arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te"
或者,要在现有通道上启用录制功能,请运行
update-channel
命令并传入录制配置 ARN:aws ivs update-channel --arn "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh" --recording-configuration-arn "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te"
-
这将为
recordingConfigurationArn
返回一个具有非“none”值的通道对象,表示已启用录制。(以下响应来自create-channel
。update-channel
响应不包括streamKey
对象。){ "channel": { "arn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "authorized": false, "ingestEndpoint": "a1b2c3d4e5f6.global-contribute.live-video.net", "insecureIngest": false, "latencyMode": "LOW", "name": "channel-live", "playbackUrl": "https://a1b2c3d4e5f6.us-west-2.playback.live-video.net/api/video/v1/us-west-2.123456789012.channel.abcdEFGH.m3u8", "recordingConfigurationArn": "arn:aws:ivs:us-west-2:123456789012:recording-configuration/mhndauNaO1te", "srt": { "endpoint": "a1b2c3d4e5f6.srt.live-video.net", "passphrase: "ZU5A3yrjGAkghUNDr0c5NXBhsPrjlmtcKMNBluh7oImwJQ3ijeyClvMKxlpPcGAMziICJ", }, "tags": {}, "type": "STANDARD" }, "streamKey": { "arn": "arn:aws:ivs:us-west-2:123456789012:stream-key/g1H2I3j4k5L6", "channelArn": "arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh", "tags": {}, "value": "sk_us-west-2_abcdABCDefgh_567890abcdef" } }
-
重要提示:记下
ingestEndpoint
、streamKey value
和playbackUrl
。您将使用它们来设置流传输和播放。