There are more AWS SDK examples available in the AWS Doc SDK Examples
MediaPackage examples using AWS CLI
The following code examples show you how to perform actions and implement common scenarios by using the AWS Command Line Interface with MediaPackage.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use create-channel
.
- AWS CLI
-
To create a channel
The following
create-channel
command creates a channel namedsportschannel
in the current account.aws mediapackage create-channel --id
sportschannel
Output:
{ "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" } }
For more information, see Creating a Channel in the AWS Elemental MediaPackage User Guide.
-
For API details, see CreateChannel
in AWS CLI Command Reference.
-
The following code example shows how to use create-origin-endpoint
.
- AWS CLI
-
To create an origin endpoint
The following
create-origin-endpoint
command creates an origin endpoint namedcmafsports
with the package settings provided in a JSON file and specified endpoint settings.aws mediapackage create-origin-endpoint \ --channel-id
sportschannel
\ --idcmafsports
\ --cmaf-packagefile://file/path/cmafpkg.json
--description"cmaf output of sports"
\ --idcmaf_sports
\ --manifest-namesports_channel
\ --startover-window-seconds300
\ --tagsregion=west,media=sports
\ --time-delay-seconds10
Output:
{ "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": [] }
For more information, see Creating an Endpoint in the AWS Elemental MediaPackage User Guide.
-
For API details, see CreateOriginEndpoint
in AWS CLI Command Reference.
-
The following code example shows how to use delete-channel
.
- AWS CLI
-
To delete a channel
The following
delete-channel
command deletes the channel namedtest
.aws mediapackage delete-channel \ --id
test
This command produces no output.
For more information, see Deleting a Channel in the AWS Elemental MediaPackage User Guide.
-
For API details, see DeleteChannel
in AWS CLI Command Reference.
-
The following code example shows how to use delete-origin-endpoint
.
- AWS CLI
-
To delete an origin endpoint
The following
delete-origin-endpoint
command deletes the origin endpoint namedtester2
.aws mediapackage delete-origin-endpoint \ --id
tester2
For more information, see Deleting an Endpoint in the AWS Elemental MediaPackage User Guide.
-
For API details, see DeleteOriginEndpoint
in AWS CLI Command Reference.
-
The following code example shows how to use describe-channel
.
- AWS CLI
-
To describe a channel
The following
describe-channel
command displays all of the details of the channel namedtest
.aws mediapackage describe-channel \ --id
test
Output:
{ "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": {} }
For more information, see Viewing Channel Details<https://docs.aws.amazon.com/mediapackage/latest/ug/channels-view.html> in the AWS Elemental MediaPackage User Guide
-
For API details, see DescribeChannel
in AWS CLI Command Reference.
-
The following code example shows how to use describe-origin-endpoint
.
- AWS CLI
-
To describe an origin endpoint
The following
describe-origin-endpoint
command displays all of the details of the origin endpoint namedcmaf_sports
.aws mediapackage describe-origin-endpoint \ --id
cmaf_sports
Output:
{ "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": [] }
For more information, see Viewing a Single Endpoint in the AWS Elemental MediaPackage User Guide.
-
For API details, see DescribeOriginEndpoint
in AWS CLI Command Reference.
-
The following code example shows how to use list-channels
.
- AWS CLI
-
To list all channels
The following
list-channels
command lists all of the channels that are configured on the current AWS account.aws mediapackage list-channels
Output:
{ "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": {} } ] }
For more information, see Viewing Channel Details in the AWS Elemental MediaPackage User Guide.
-
For API details, see ListChannels
in AWS CLI Command Reference.
-
The following code example shows how to use list-origin-endpoints
.
- AWS CLI
-
To list all origin-endpoints on a channel
The following
list-origin-endpoints
command lists all of the origin endpoints that are configured on the channel namedtest
.aws mediapackage list-origin-endpoints \ --channel-id
test
Output:
{ "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": [] } ] }
For more information, see Viewing all Endpoints Associated with a Channel in the AWS Elemental MediaPackage User Guide.
-
For API details, see ListOriginEndpoints
in AWS CLI Command Reference.
-
The following code example shows how to use list-tags-for-resource
.
- AWS CLI
-
To list the tags assigned to a resource
The following
list-tags-for-resource
command lists the tags that are assigned to the specified resource.aws mediapackage list-tags-for-resource \ --resource-arn
arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0
Output:
{ "Tags": { "region": "west" } }
For more information, see Tagging Resources in AWS Elemental MediaPackage in the AWS Elemental MediaPackage User Guide.
-
For API details, see ListTagsForResource
in AWS CLI Command Reference.
-
The following code example shows how to use rotate-ingest-endpoint-credentials
.
- AWS CLI
-
To rotate ingest credentials
The following
rotate-ingest-endpoint-credentials
command rotates the WebDAV username and password for the specified ingest endpoint.aws mediapackage rotate-ingest-endpoint-credentials \ --id
test
\ --ingest-endpoint-id584797f1740548c389a273585dd22a63
Output:
{ "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": {} }
For more information, see Rotating Credentials on an Input URL in the AWS Elemental MediaPackage User Guide.
-
For API details, see RotateIngestEndpointCredentials
in AWS CLI Command Reference.
-
The following code example shows how to use tag-resource
.
- AWS CLI
-
To add a tag to a resource
The following
tag-resource
commands adds aregion=west
key and value pair to the specified resource.aws mediapackage tag-resource \ --resource-arn
arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0
\ --tagsregion=west
This command produces no output.
For more information, see Tagging Resources in AWS Elemental MediaPackage in the AWS Elemental MediaPackage User Guide.
-
For API details, see TagResource
in AWS CLI Command Reference.
-
The following code example shows how to use untag-resource
.
- AWS CLI
-
To remove a tag from a resource
The following
untag-resource
command removes the tag with the keyregion
from the specified channel.aws mediapackage untag-resource \ --resource-arn
arn:aws:mediapackage:us-west-2:111222333:channels/6d345804ec3f46c9b454a91d4a80d0e0
\ --tag-keysregion
For more information, see Tagging Resources in AWS Elemental MediaPackage in the AWS Elemental MediaPackage User Guide.
-
For API details, see UntagResource
in AWS CLI Command Reference.
-
The following code example shows how to use update-channel
.
- AWS CLI
-
To update a channel
The following
update-channel
command updates the channel namedsportschannel
to include the description24x7 sports
.aws mediapackage update-channel \ --id
sportschannel
\ --description"24x7 sports"
Output:
{ "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": {} }
For more information, see Editing a Channel in the AWS Elemental MediaPackage User Guide.
-
For API details, see UpdateChannel
in AWS CLI Command Reference.
-
The following code example shows how to use update-origin-endpoint
.
- AWS CLI
-
To update an origin endpoint
The following
update-origin-endpoint
command updates the origin endpoint namedcmaf_sports
. It changes the time delay to0
seconds.aws mediapackage update-origin-endpoint \ --id
cmaf_sports
\ --time-delay-seconds0
Output:
{ "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": [] }
For more information, see Editing an Endpoint in the AWS Elemental MediaPackage User Guide.
-
For API details, see UpdateOriginEndpoint
in AWS CLI Command Reference.
-