MediaConnect 使用示例 AWS CLI - AWS SDK代码示例

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

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

MediaConnect 使用示例 AWS CLI

以下代码示例向您展示了如何使用with来执行操作和实现常见场景 MediaConnect。 AWS Command Line Interface

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

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

主题

操作

以下代码示例演示如何使用 add-flow-outputs

AWS CLI

向流程中添加输出

以下add-flow-outputs示例将输出添加到指定流程。

aws mediaconnect add-flow-outputs \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --outputs Description='NYC stream',Destination=192.0.2.12,Name=NYC,Port=3333,Protocol=rtp-fec,SmoothingLatency=100 Description='LA stream',Destination=203.0.113.9,Name=LA,Port=4444,Protocol=rtp-fec,SmoothingLatency=100

输出:

{ "Outputs": [ { "Port": 3333, "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC", "Name": "NYC", "Description": "NYC stream", "Destination": "192.0.2.12", "Transport": { "Protocol": "rtp-fec", "SmoothingLatency": 100 } }, { "Port": 4444, "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-987655dEF67hiJ89-c34de5fG678h:LA", "Name": "LA", "Description": "LA stream", "Destination": "203.0.113.9", "Transport": { "Protocol": "rtp-fec", "SmoothingLatency": 100 } } ], "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame" }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的向流程添加输出

以下代码示例演示如何使用 create-flow

AWS CLI

创建流程

以下create-flow示例使用指定配置创建流程。

aws mediaconnect create-flow \ --availability-zone us-west-2c \ --name ExampleFlow \ --source Description='Example source, backup',IngestPort=1055,Name=BackupSource,Protocol=rtp,WhitelistCidr=10.24.34.0/23

输出:

{ "Flow": { "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:ExampleFlow", "AvailabilityZone": "us-west-2c", "EgressIp": "54.245.71.21", "Source": { "IngestPort": 1055, "SourceArn": "arn:aws:mediaconnect:us-east-1:123456789012:source:2-3aBC45dEF67hiJ89-c34de5fG678h:BackupSource", "Transport": { "Protocol": "rtp", "MaxBitrate": 80000000 }, "Description": "Example source, backup", "IngestIp": "54.245.71.21", "WhitelistCidr": "10.24.34.0/23", "Name": "mySource" }, "Entitlements": [], "Name": "ExampleFlow", "Outputs": [], "Status": "STANDBY", "Description": "Example source, backup" } }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的创建流程

以下代码示例演示如何使用 delete-flow

AWS CLI

删除流程

以下delete-flow示例删除了指定的流程。

aws mediaconnect delete-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Status": "DELETING" }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的删除流程

以下代码示例演示如何使用 describe-flow

AWS CLI

查看流程的详细信息

以下describe-flow示例显示了指定流程的详细信息,例如ARN可用区、状态、来源、授权和输出。

aws mediaconnect describe-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

输出:

{ "Flow": { "EgressIp": "54.201.4.39", "AvailabilityZone": "us-west-2c", "Status": "ACTIVE", "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Entitlements": [ { "EntitlementArn": "arn:aws:mediaconnect:us-west-2:123456789012:entitlement:1-AaBb11CcDd22EeFf-34DE5fG12AbC:MyEntitlement", "Description": "Assign to this account", "Name": "MyEntitlement", "Subscribers": [ "444455556666" ] } ], "Description": "NYC awards show", "Name": "AwardsShow", "Outputs": [ { "Port": 2355, "Name": "NYC", "Transport": { "SmoothingLatency": 0, "Protocol": "rtp-fec" }, "OutputArn": "arn:aws:mediaconnect:us-east-1:123456789012:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC", "Destination": "192.0.2.0" }, { "Port": 3025, "Name": "LA", "Transport": { "SmoothingLatency": 0, "Protocol": "rtp-fec" }, "OutputArn": "arn:aws:mediaconnect:us-east-1:123456789012:output:2-987655dEF67hiJ89-c34de5fG678h:LA", "Destination": "192.0.2.0" } ], "Source": { "IngestIp": "54.201.4.39", "SourceArn": "arn:aws:mediaconnect:us-east-1:123456789012:source:3-4aBC56dEF78hiJ90-4de5fG6Hi78Jk:ShowSource", "Transport": { "MaxBitrate": 80000000, "Protocol": "rtp" }, "IngestPort": 1069, "Description": "Saturday night show", "Name": "ShowSource", "WhitelistCidr": "10.24.34.0/23" } } }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的查看流程的详细信息

以下代码示例演示如何使用 grant-flow-entitlements

AWS CLI

授予流程权限

以下grant-flow-entitlements示例向指定的现有流程授予与其他 AWS 账户共享您的内容的权限。

aws mediaconnect grant-flow-entitlements \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --entitlements Description='For AnyCompany',Encryption={"Algorithm=aes128,KeyType=static-key,RoleArn=arn:aws:iam::111122223333:role/MediaConnect-ASM,SecretArn=arn:aws:secretsmanager:us-west-2:111122223333:secret:mySecret1"},Name=AnyCompany_Entitlement,Subscribers=444455556666 Description='For Example Corp',Name=ExampleCorp,Subscribers=777788889999

输出:

{ "Entitlements": [ { "Name": "AnyCompany_Entitlement", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement", "Subscribers": [ "444455556666" ], "Description": "For AnyCompany", "Encryption": { "SecretArn": "arn:aws:secretsmanager:us-west-2:111122223333:secret:mySecret1", "Algorithm": "aes128", "RoleArn": "arn:aws:iam::111122223333:role/MediaConnect-ASM", "KeyType": "static-key" } }, { "Name": "ExampleCorp", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-3333cccc4444dddd-1111aaaa2222:ExampleCorp", "Subscribers": [ "777788889999" ], "Description": "For Example Corp" } ], "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame" }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的授予流程权限。

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

AWS CLI

查看权利列表

以下list-entitlements示例显示了已授予该账户的所有权利的列表。

aws mediaconnect list-entitlements

输出:

{ "Entitlements": [ { "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:MyEntitlement", "EntitlementName": "MyEntitlement" } ] }

有关更多信息,请参阅《AWS 元素 MediaConnect API参考ListEntitlements中的。

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

AWS CLI

查看流程列表

以下list-flows示例显示了流程列表。

aws mediaconnect list-flows

输出:

{ "Flows": [ { "Status": "STANDBY", "SourceType": "OWNED", "AvailabilityZone": "us-west-2a", "Description": "NYC awards show", "Name": "AwardsShow", "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow" }, { "Status": "STANDBY", "SourceType": "OWNED", "AvailabilityZone": "us-west-2c", "Description": "LA basketball game", "Name": "BasketballGame", "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame" } ] }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的查看流程列表

以下代码示例演示如何使用 list-tags-for-resource

AWS CLI

列出 MediaConnect 资源的标签

以下list-tags-for-resource示例显示了与指定 MediaConnect 资源关联的标签键和值。

aws mediaconnect list-tags-for-resource \ --resource-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame

输出:

{ "Tags": { "region": "west", "stage": "prod" } }

有关更多信息 ListTagsForResource TagResource,请参阅《AWS 元素 MediaConnect API参考》 UntagResource中的。

以下代码示例演示如何使用 remove-flow-output

AWS CLI

从流程中移除输出

以下remove-flow-output示例从指定流程中移除输出。

aws mediaconnect remove-flow-output \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --output-arn arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC" }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的从流程中移除输出

以下代码示例演示如何使用 revoke-flow-entitlement

AWS CLI

撤销授权

以下revoke-flow-entitlement示例撤消了指定流程上的授权。

aws mediaconnect revoke-flow-entitlement \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --entitlement-arn arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement" }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的撤销授权

以下代码示例演示如何使用 start-flow

AWS CLI

启动流程

以下start-flow示例启动指定的流程。

aws mediaconnect start-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

此命令不生成任何输出。输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Status": "STARTING" }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的启动流程

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

AWS CLI

停止流动

以下stop-flow示例停止指定的流程。

aws mediaconnect stop-flow \ --flow-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow

输出:

{ "Status": "STOPPING", "FlowArn": "arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow" }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的停止数据流

以下代码示例演示如何使用 tag-resource

AWS CLI

为 MediaConnect 资源添加标签

以下tag-resource示例向指定 MediaConnect 资源添加带有密钥名称和值的标签。

aws mediaconnect tag-resource \ --resource-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame --tags region=west

此命令不生成任何输出。

有关更多信息 ListTagsForResource TagResource,请参阅《AWS 元素 MediaConnect API参考》 UntagResource中的。

以下代码示例演示如何使用 untag-resource

AWS CLI

从 MediaConnect 资源中移除标签

以下untag-resource示例从 MediaConnect 资源中移除具有指定密钥名称及其关联值的标签。

aws mediaconnect untag-resource \ --resource-arn arn:aws:mediaconnect:us-east-1:123456789012:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BasketballGame \ --tag-keys region

此命令不生成任何输出。

有关更多信息 ListTagsForResource TagResource,请参阅《AWS 元素 MediaConnect API参考》 UntagResource中的。

以下代码示例演示如何使用 update-flow-entitlement

AWS CLI

更新权利

以下update-flow-entitlement示例使用新的描述和订阅者更新了指定的权利。

aws mediaconnect update-flow-entitlement \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --entitlement-arn arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement \ --description 'For AnyCompany Affiliate' \ --subscribers 777788889999

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "Entitlement": { "Name": "AnyCompany_Entitlement", "Description": "For AnyCompany Affiliate", "EntitlementArn": "arn:aws:mediaconnect:us-west-2:111122223333:entitlement:1-11aa22bb11aa22bb-3333cccc4444:AnyCompany_Entitlement", "Encryption": { "KeyType": "static-key", "Algorithm": "aes128", "RoleArn": "arn:aws:iam::111122223333:role/MediaConnect-ASM", "SecretArn": "arn:aws:secretsmanager:us-west-2:111122223333:secret:mySecret1" }, "Subscribers": [ "777788889999" ] } }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的更新授权

以下代码示例演示如何使用 update-flow-output

AWS CLI

更新流程的输出

以下update-flow-output示例更新指定流程的输出。

aws mediaconnect update-flow-output \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame \ --output-arn arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC \ --port 3331

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:BaseballGame", "Output": { "Name": "NYC", "Port": 3331, "Description": "NYC stream", "Transport": { "Protocol": "rtp-fec", "SmoothingLatency": 100 }, "OutputArn": "arn:aws:mediaconnect:us-east-1:111122223333:output:2-3aBC45dEF67hiJ89-c34de5fG678h:NYC", "Destination": "192.0.2.12" } }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的更新流程输出

以下代码示例演示如何使用 update-flow-source

AWS CLI

更新现有流程的来源

以下update-flow-source示例更新了现有流程的来源。

aws mediaconnect update-flow-source \ --flow-arn arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow \ --source-arn arn:aws:mediaconnect:us-east-1:111122223333:source:3-4aBC56dEF78hiJ90-4de5fG6Hi78Jk:ShowSource \ --description 'Friday night show' \ --ingest-port 3344 \ --protocol rtp-fec \ --whitelist-cidr 10.24.34.0/23

输出:

{ "FlowArn": "arn:aws:mediaconnect:us-east-1:111122223333:flow:1-23aBC45dEF67hiJ8-12AbC34DE5fG:AwardsShow", "Source": { "IngestIp": "34.210.136.56", "WhitelistCidr": "10.24.34.0/23", "Transport": { "Protocol": "rtp-fec" }, "IngestPort": 3344, "Name": "ShowSource", "Description": "Friday night show", "SourceArn": "arn:aws:mediaconnect:us-east-1:111122223333:source:3-4aBC56dEF78hiJ90-4de5fG6Hi78Jk:ShowSource" } }

有关更多信息,请参阅 AWS Elemental MediaConnect 用户指南中的更新流程来源