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

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

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

MediaPackage 使用示例 AWS CLI

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

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

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

主题

操作

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

AWS CLI

创建频道

以下create-channel命令创建一个以当前账号命名的sportschannel频道。

aws mediapackage create-channel --id sportschannel

输出:

{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0", "HlsIngest": { "IngestEndpoints": [ { "Id": "6d345804ec3f46c9b454a91d4a80d0e0", "Password": "generatedwebdavpassword1", "Url": "https://f31c86aed53b815a.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/6d345804ec3f46c9b454a91d4a80d0e0/channel", "Username": "generatedwebdavusername1" }, { "Id": "2daa32878af24803b24183727211b8ff", "Password": "generatedwebdavpassword2", "Url": "https://6ebbe7e04c4b0afa.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/2daa32878af24803b24183727211b8ff/channel", "Username": "generatedwebdavusername2" } ] }, "Id": "sportschannel", "Tags": { "region": "west" } }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的创建频道

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

AWS CLI

创建源端点

以下create-origin-endpoint命令cmafsports使用JSON文件中提供的软件包设置和指定的端点设置创建名为的源端点。

aws mediapackage create-origin-endpoint \ --channel-id sportschannel \ --id cmafsports \ --cmaf-package file://file/path/cmafpkg.json --description "cmaf output of sports" \ --id cmaf_sports \ --manifest-name sports_channel \ --startover-window-seconds 300 \ --tags region=west,media=sports \ --time-delay-seconds 10

输出:

{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/1dc6718be36f4f34bb9cd86bc50925e6", "ChannelId": "sportschannel", "CmafPackage": { "HlsManifests": [ { "AdMarkers": "PASSTHROUGH", "Id": "cmaf_sports_endpoint", "IncludeIframeOnlyStream": true, "ManifestName": "index", "PlaylistType": "EVENT", "PlaylistWindowSeconds": 300, "ProgramDateTimeIntervalSeconds": 300, "Url": "https://c4af3793bf76b33c.mediapackage.us-west-2.amazonaws.com/out/v1/1dc6718be36f4f34bb9cd86bc50925e6/cmaf_sports_endpoint/index.m3u8" } ], "SegmentDurationSeconds": 2, "SegmentPrefix": "sportschannel" }, "Description": "cmaf output of sports", "Id": "cmaf_sports", "ManifestName": "sports_channel", "StartoverWindowSeconds": 300, "Tags": { "region": "west", "media": "sports" }, "TimeDelaySeconds": 10, "Url": "", "Whitelist": [] }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的创建端点

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

AWS CLI

删除频道

以下delete-channel命令删除名为的频道test

aws mediapackage delete-channel \ --id test

此命令不生成任何输出。

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的删除频道

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

AWS CLI

删除源端点

以下delete-origin-endpoint命令删除名为的源端点tester2

aws mediapackage delete-origin-endpoint \ --id tester2

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的删除端点

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

AWS CLI

描述频道

以下describe-channel命令显示名为的频道的所有详细信息test

aws mediapackage describe-channel \ --id test

输出:

{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/584797f1740548c389a273585dd22a63", "HlsIngest": { "IngestEndpoints": [ { "Id": "584797f1740548c389a273585dd22a63", "Password": "webdavgeneratedpassword1", "Url": "https://9be9c4405c474882.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/584797f1740548c389a273585dd22a63/channel", "Username": "webdavgeneratedusername1" }, { "Id": "7d187c8616fd455f88aaa5a9fcf74442", "Password": "webdavgeneratedpassword2", "Url": "https://7bf454c57220328d.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/7d187c8616fd455f88aaa5a9fcf74442/channel", "Username": "webdavgeneratedusername2" } ] }, "Id": "test", "Tags": {} }

有关更多信息,请参阅 Elemental 用户指南中的查看频道详情< https://docs.aws.amazon.com/mediapackage/ latest/ug/channels-view.html>AWS MediaPackage

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

AWS CLI

描述源端点

以下describe-origin-endpoint命令显示名为的源端点的所有详细信息cmaf_sports

aws mediapackage describe-origin-endpoint \ --id cmaf_sports

输出:

{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/1dc6718be36f4f34bb9cd86bc50925e6", "ChannelId": "sportschannel", "CmafPackage": { "HlsManifests": [ { "AdMarkers": "NONE", "Id": "cmaf_sports_endpoint", "IncludeIframeOnlyStream": false, "PlaylistType": "EVENT", "PlaylistWindowSeconds": 60, "ProgramDateTimeIntervalSeconds": 0, "Url": "https://c4af3793bf76b33c.mediapackage.us-west-2.amazonaws.com/out/v1/1dc6718be36f4f34bb9cd86bc50925e6/cmaf_sports_endpoint/index.m3u8" } ], "SegmentDurationSeconds": 2, "SegmentPrefix": "sportschannel" }, "Id": "cmaf_sports", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": { "region": "west", "media": "sports" }, "TimeDelaySeconds": 0, "Url": "", "Whitelist": [] }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的查看单个端点

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

AWS CLI

列出所有通道

以下list-channels命令列出了在当前 AWS 账户上配置的所有频道。

aws mediapackage list-channels

输出:

{ "Channels": [ { "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/584797f1740548c389a273585dd22a63", "HlsIngest": { "IngestEndpoints": [ { "Id": "584797f1740548c389a273585dd22a63", "Password": "webdavgeneratedpassword1", "Url": "https://9be9c4405c474882.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/584797f1740548c389a273585dd22a63/channel", "Username": "webdavgeneratedusername1" }, { "Id": "7d187c8616fd455f88aaa5a9fcf74442", "Password": "webdavgeneratedpassword2", "Url": "https://7bf454c57220328d.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/7d187c8616fd455f88aaa5a9fcf74442/channel", "Username": "webdavgeneratedusername2" } ] }, "Id": "test", "Tags": {} } ] }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的查看频道详情

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

AWS CLI

列出通道上的所有源端点

以下 list-origin-endpoints 命令列出了名为 test 的通道中配置的所有源端点。

aws mediapackage list-origin-endpoints \ --channel-id test

输出:

{ "OriginEndpoints": [ { "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/247cff871f2845d3805129be22f2c0a2", "ChannelId": "test", "DashPackage": { "ManifestLayout": "FULL", "ManifestWindowSeconds": 60, "MinBufferTimeSeconds": 30, "MinUpdatePeriodSeconds": 15, "PeriodTriggers": [], "Profile": "NONE", "SegmentDurationSeconds": 2, "SegmentTemplateFormat": "NUMBER_WITH_TIMELINE", "StreamSelection": { "MaxVideoBitsPerSecond": 2147483647, "MinVideoBitsPerSecond": 0, "StreamOrder": "ORIGINAL" }, "SuggestedPresentationDelaySeconds": 25 }, "Id": "tester2", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": {}, "TimeDelaySeconds": 0, "Url": "https://8343f7014c0ea438.mediapackage.us-west-2.amazonaws.com/out/v1/247cff871f2845d3805129be22f2c0a2/index.mpd", "Whitelist": [] }, { "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/869e237f851549e9bcf10e3bc2830839", "ChannelId": "test", "HlsPackage": { "AdMarkers": "NONE", "IncludeIframeOnlyStream": false, "PlaylistType": "EVENT", "PlaylistWindowSeconds": 60, "ProgramDateTimeIntervalSeconds": 0, "SegmentDurationSeconds": 6, "StreamSelection": { "MaxVideoBitsPerSecond": 2147483647, "MinVideoBitsPerSecond": 0, "StreamOrder": "ORIGINAL" }, "UseAudioRenditionGroup": false }, "Id": "tester", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": {}, "TimeDelaySeconds": 0, "Url": "https://8343f7014c0ea438.mediapackage.us-west-2.amazonaws.com/out/v1/869e237f851549e9bcf10e3bc2830839/index.m3u8", "Whitelist": [] } ] }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的查看与频道关联的所有端点

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

AWS CLI

列出分配给资源的标签

以下list-tags-for-resource命令列出了分配给指定资源的标签。

aws mediapackage list-tags-for-resource \ --resource-arn arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0

输出:

{ "Tags": { "region": "west" } }

有关更多信息,请参阅《元素用户指南》中的 “在 AWS Elemental MediaPackage 中为AWS 资源添加标签”。 MediaPackage

以下代码示例演示如何使用 rotate-ingest-endpoint-credentials

AWS CLI

轮换采集凭证

以下rotate-ingest-endpoint-credentials命令轮换指定采集端点的 Web DAV 用户名和密码。

aws mediapackage rotate-ingest-endpoint-credentials \ --id test \ --ingest-endpoint-id 584797f1740548c389a273585dd22a63

输出:

{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/584797f1740548c389a273585dd22a63", "HlsIngest": { "IngestEndpoints": [ { "Id": "584797f1740548c389a273585dd22a63", "Password": "webdavregeneratedpassword1", "Url": "https://9be9c4405c474882.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/584797f1740548c389a273585dd22a63/channel", "Username": "webdavregeneratedusername1" }, { "Id": "7d187c8616fd455f88aaa5a9fcf74442", "Password": "webdavgeneratedpassword2", "Url": "https://7bf454c57220328d.mediapackage.us-west-2.amazonaws.com/in/v2/584797f1740548c389a273585dd22a63/7d187c8616fd455f88aaa5a9fcf74442/channel", "Username": "webdavgeneratedusername2" } ] }, "Id": "test", "Tags": {} }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南URL中的轮换输入凭证

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

AWS CLI

要将标签添加到资源中

以下tag-resource命令将region=west键值对添加到指定资源。

aws mediapackage tag-resource \ --resource-arn arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0 \ --tags region=west

此命令不生成任何输出。

有关更多信息,请参阅《元素用户指南》中的 “在 AWS Elemental MediaPackage 中为AWS 资源添加标签”。 MediaPackage

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

AWS CLI

从资源中移除标签

以下untag-resource命令region从指定频道中删除带有密钥的标签。

aws mediapackage untag-resource \ --resource-arn arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0 \ --tag-keys region

有关更多信息,请参阅《元素用户指南》中的 “在 AWS Elemental MediaPackage 中为AWS 资源添加标签”。 MediaPackage

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

AWS CLI

更新频道

以下update-channel命令更新名为的频道sportschannel以包含描述24x7 sports

aws mediapackage update-channel \ --id sportschannel \ --description "24x7 sports"

输出:

{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0", "Description": "24x7 sports", "HlsIngest": { "IngestEndpoints": [ { "Id": "6d345804ec3f46c9b454a91d4a80d0e0", "Password": "generatedwebdavpassword1", "Url": "https://f31c86aed53b815a.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/6d345804ec3f46c9b454a91d4a80d0e0/channel", "Username": "generatedwebdavusername1" }, { "Id": "2daa32878af24803b24183727211b8ff", "Password": "generatedwebdavpassword2", "Url": "https://6ebbe7e04c4b0afa.mediapackage.us-west-2.amazonaws.com/in/v2/6d345804ec3f46c9b454a91d4a80d0e0/2daa32878af24803b24183727211b8ff/channel", "Username": "generatedwebdavusername2" } ] }, "Id": "sportschannel", "Tags": {} }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的编辑频道

以下代码示例演示如何使用 update-origin-endpoint

AWS CLI

更新源端点

以下update-origin-endpoint命令更新名为的源端点cmaf_sports。它将延迟时间更改为0秒。

aws mediapackage update-origin-endpoint \ --id cmaf_sports \ --time-delay-seconds 0

输出:

{ "Arn": "arn:aws:mediapackage:us-west-2:111222333:origin_endpoints/1dc6718be36f4f34bb9cd86bc50925e6", "ChannelId": "sportschannel", "CmafPackage": { "HlsManifests": [ { "AdMarkers": "NONE", "Id": "cmaf_sports_endpoint", "IncludeIframeOnlyStream": false, "PlaylistType": "EVENT", "PlaylistWindowSeconds": 60, "ProgramDateTimeIntervalSeconds": 0, "Url": "https://c4af3793bf76b33c.mediapackage.us-west-2.amazonaws.com/out/v1/1dc6718be36f4f34bb9cd86bc50925e6/cmaf_sports_endpoint/index.m3u8" } ], "SegmentDurationSeconds": 2, "SegmentPrefix": "sportschannel" }, "Id": "cmaf_sports", "ManifestName": "index", "StartoverWindowSeconds": 0, "Tags": { "region": "west", "media": "sports" }, "TimeDelaySeconds": 0, "Url": "", "Whitelist": [] }

有关更多信息,请参阅 AWS Elemental MediaPackage 用户指南中的编辑端点