本文档 AWS CLI 仅适用于版本 1。有关版本 2 的文档 AWS CLI,请参阅版本 2 用户指南。
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
使用亚马逊的IVS示例 AWS CLI
以下代码示例向您展示如何在 Amazon 中使用来执行操作和实现常见场景IVS。 AWS Command Line Interface
操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。
每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。
主题
操作
以下代码示例显示了如何使用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低延迟用户指南》中的创建频道。
-
有关API详细信息,请参阅 “BatchGetStreamKey AWS CLI
命令参考”。
-
以下代码示例显示了如何使用batch-start-viewer-session-revocation
。
- AWS CLI
-
撤消多对频道ARN和观众 ID 对的观看者会话
以下
batch-start-viewer-session-revocation
示例同时对多个频道ARN和 Viewer-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 Interactive Video Service 用户指南》中的设置私有通道。
-
有关API详细信息,请参阅 “BatchStartViewerSessionRevocation AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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-countriesUS
MX
\ --allowed-originshttps://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低延迟用户指南》中的不想要的内容和查看者。
-
有关API详细信息,请参阅 “CreatePlaybackRestrictionPolicy AWS CLI
命令参考”。
-
以下代码示例显示了如何使用create-recording-configuration
。
- AWS CLI
-
创建 RecordingConfiguration 资源
以下
create-recording-configuration
示例创建了一个 RecordingConfiguration 资源以启用录制到 Amazon S3。aws ivs create-recording-configuration \ --name
"test-recording-config"
\ --recording-reconnect-window-seconds60
\ --tags"key1=value1, key2=value2"
\ --rendition-configuration renditionSelection="CUSTOM",renditions="HD" \ --thumbnail-configuration recordingMode="INTERVAL",targetIntervalSeconds=1,storage="LATEST",resolution="LOWEST_RESOLUTION" \ --destination-configurations3={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 S3”。
-
有关API详细信息,请参阅 “CreateRecordingConfiguration AWS CLI
命令参考”。
-
以下代码示例显示了如何使用create-stream-key
。
- AWS CLI
-
创建直播密钥
以下
create-stream-key
示例为指定的ARN(Amazon 资源名称)创建流密钥。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 资源名称)的频道。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
-
删除指定的回放 key pair
以下
delete-playback-key-pair
示例返回指定 key pair 的指纹。aws ivs delete-playback-key-pair \ --arn
arn:aws:ivs:us-west-2:123456789012:playback-key/abcd1234efgh
此命令不生成任何输出。
有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的设置私有通道。
-
有关API详细信息,请参阅 “DeletePlaybackKeyPair AWS CLI
命令参考”。
-
以下代码示例显示了如何使用delete-playback-restriction-policy
。
- AWS CLI
-
删除播放限制政策
以下
delete-playback-restriction-policy
示例删除了具有指定政策(ARNAmazon 资源名称)的播放限制政策。aws ivs delete-playback-restriction-policy \ --arn
"arn:aws:ivs:us-west-2:123456789012:playback-restriction-policy/ABcdef34ghIJ"
此命令不生成任何输出。
有关更多信息,请参阅《IVS低延迟用户指南》中的不想要的内容和查看者。
-
有关API详细信息,请参阅 “DeletePlaybackRestrictionPolicy AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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 S3”。
-
有关API详细信息,请参阅 “DeleteRecordingConfiguration AWS CLI
命令参考”。
-
以下代码示例显示了如何使用delete-stream-key
。
- AWS CLI
-
删除直播密钥
以下
delete-stream-key
示例删除了指定ARN(Amazon 资源名称)的直播密钥,因此该密钥不能再用于流式传输。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 资源名称)。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
-
获取指定的播放 key pair
以下
get-playback-key-pair
示例返回指定 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 Interactive Video Service 用户指南》中的设置私有通道。
-
有关API详细信息,请参阅 “GetPlaybackKeyPair AWS CLI
命令参考”。
-
以下代码示例显示了如何使用get-playback-restriction-policy
。
- AWS CLI
-
获取播放限制策略的配置信息
以下
get-playback-restriction-policy
示例使用指定策略ARN(Amazon 资源名称)获取播放限制策略配置。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低延迟用户指南》中的不想要的内容和查看者。
-
有关API详细信息,请参阅 “GetPlaybackRestrictionPolicy AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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 S3”。
-
有关API详细信息,请参阅 “GetRecordingConfiguration AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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 资源名称)和指定直播的元数据配置;如果 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
-
导入新 key pair 的公共部分
以下
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 Interactive Video Service 用户指南》中的设置私有通道。
-
有关API详细信息,请参阅 “ImportPlaybackKeyPair AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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 Interactive Video Service 用户指南》中的设置私有通道。
-
有关API详细信息,请参阅 “ListPlaybackKeyPairs AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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低延迟用户指南》中的不想要的内容和查看者。
-
有关API详细信息,请参阅 “ListPlaybackRestrictionPolicies AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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 S3”。
-
有关API详细信息,请参阅 “ListRecordingConfigurations AWS CLI
命令参考”。
-
以下代码示例显示了如何使用list-stream-keys
。
- AWS CLI
-
获取直播密钥列表
以下
list-stream-keys
示例列出了指定ARN(Amazon 资源名称)的所有流密钥。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 资源名称)。aws ivs list-stream-sessions \ --channel-arn
arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh
\ --max-results25
\ --next-token ""输出:
{ "nextToken": "set-2", "streamSessions": [ { "startTime": 1641578182, "endTime": 1641579982, "hasErrorEvent": false, "streamId": "mystream" } ... ] }
有关更多信息,请参阅《IVS低延迟用户指南》中的创建频道。
-
有关API详细信息,请参阅 “ListStreamSessions AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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 资源名称)的所有标签。aws ivs list-tags-for-resource \ --resource-arn
arn:aws:ivs:us-west-2:12345689012:channel/abcdABCDefgh
输出:
{ "tags": { "key1": "value1", "key2": "value2" } }
有关更多信息,请参阅《Amazon 互动视频服务API参考》中的 “添加标签”。
-
有关API详细信息,请参阅 “ListTagsForResource AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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-idabcdefg
\ --viewer-session-versions-less-than-or-equal-to1234567890
此命令不生成任何输出。
有关更多信息,请参阅《Amazon Interactive Video Service 用户指南》中的设置私有通道。
-
有关API详细信息,请参阅 “StartViewerSessionRevocation AWS CLI
命令参考”。
-
以下代码示例显示了如何使用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 资源名称)添加或更新标签。aws ivs tag-resource \ --resource-arn
arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh
\ --tags"tagkey1=tagvalue1, tagkey2=tagvalue2"
此命令不生成任何输出。
有关更多信息,请参阅《Amazon 互动视频服务API参考》中的 “添加标签”。
-
有关API详细信息,请参阅 “TagResource AWS CLI
命令参考”。
-
以下代码示例显示了如何使用untag-resource
。
- AWS CLI
-
移除 AWS 资源的标签(例如:频道、直播密钥)
以下
untag-resource
示例删除了指定资源ARN(Amazon 资源名称)的指定标签。aws ivs untag-resource \ --resource-arn
arn:aws:ivs:us-west-2:123456789012:channel/abcdABCDefgh
\ --tag-keys"tagkey1, tagkey2"
此命令不生成任何输出。
有关更多信息,请参阅《Amazon 互动视频服务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低延迟用户指南》中的不想要的内容和查看者。
-
有关API详细信息,请参阅 “UpdatePlaybackRestrictionPolicy AWS CLI
命令参考”。
-