This documentation is for Version 1 of the Amazon CLI only. For documentation related to Version 2 of the Amazon CLI, see the Version 2 User Guide.
MediaLive examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with MediaLive.
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
.
- Amazon CLI
-
To create a channel
The following
create-channel
example creates a channel by passing in a JSON file that contains the parameters that you want to specify.The channel in this example ingests an HLS PULL input that connects to a source that contains video, audio, and embedded captions. The channel creates one HLS output group with an Akamai server as the destination. The output group contains two outputs: one for the H.265 video and AAC audio, and one for the Web-VTT captions, in English only.
The JSON for this example channel includes the minimum required parameters for a channel that uses an HLS PULL input and that produces an HLS output group with Akamai as the destination. The JSON contains these main sections:
InputAttachments
, which specifies one source for the audio, and one source for the captions. It does not specify a video selector, which means that MediaLive extracts the first video it finds in the source.Destinations
, which contains the two IP addresses (URLs) for the single output group in this channel. These addresses require passwords.EncoderSettings
, which contains subsections.AudioDescriptions
, which specifies that the channel contains one audio output asset, which uses the source from InputAttachments, and produces audio in AAC format.CaptionDescriptions
, which specifies that the channel contains one captions output asset, which uses the source from InputAttachments, and produces captions in Web-VTT format.VideoDescriptions
, which specifies that the channel contains one video output asset, with the specified resolution.OutputGroups
, which specifies the output groups. In this example there is one group namedAkamai
. The connection is made using HLS PUT. The output group contains two outputs. One output is for the video asset (namedVideo_high
) and the audio asset (namedAudio_EN
). One output is for the captions asset (namedWebVTT_EN
).In this example, some of the parameters contain no value or contain nested empty parameters. For example, OutputSettings for the
Video_and_audio
output contains several nested parameters that end at an empty parameter M3u8Settings. This parameter must be included, but you can omit one, several, or all its children, which means that the child will take its default value or be null.All the parameters that apply to this example channel but that aren't specified in this file will either take the default value, be set to null, or take a unique value generated by MediaLive.
aws medialive create-channel \ --cli-input-json
file://channel-in-hls-out-hls-akamai.json
Contents of
channel-in-hls-out-hls-akamai.json
:{ "Name": "News_West", "RoleArn": "arn:aws:iam::111122223333:role/MediaLiveAccessRole", "InputAttachments": [ { "InputAttachmentName": "local_news", "InputId": "1234567", "InputSettings": { "AudioSelectors": [ { "Name": "English-Audio", "SelectorSettings": { "AudioLanguageSelection": { "LanguageCode": "EN" } } } ], "CaptionSelectors": [ { "LanguageCode": "ENE", "Name": "English_embedded" } ] } } ], "Destinations": [ { "Id": "akamai-server-west", "Settings": [ { "PasswordParam": "/medialive/examplecorp1", "Url": "http://203.0.113.55/news/news_west", "Username": "examplecorp" }, { "PasswordParam": "/medialive/examplecorp2", "Url": "http://203.0.113.82/news/news_west", "Username": "examplecorp" } ] } ], "EncoderSettings": { "AudioDescriptions": [ { "AudioSelectorName": "English-Audio", "CodecSettings": { "AacSettings": {} }, "Name": "Audio_EN" } ], "CaptionDescriptions": [ { "CaptionSelectorName": "English_embedded", "DestinationSettings": { "WebvttDestinationSettings": {} }, "Name": "WebVTT_EN" } ], "VideoDescriptions": [ { "Height": 720, "Name": "Video_high", "Width": 1280 } ], "OutputGroups": [ { "Name": "Akamai", "OutputGroupSettings": { "HlsGroupSettings": { "Destination": { "DestinationRefId": "akamai-server-west" }, "HlsCdnSettings": { "HlsBasicPutSettings": {} } } }, "Outputs": [ { "AudioDescriptionNames": [ "Audio_EN" ], "OutputName": "Video_and_audio", "OutputSettings": { "HlsOutputSettings": { "HlsSettings": { "StandardHlsSettings": { "M3u8Settings": {} } }, "NameModifier": "_1" } }, "VideoDescriptionName": "Video_high" }, { "CaptionDescriptionNames": [ "WebVTT_EN" ], "OutputName": "Captions-WebVTT", "OutputSettings": { "HlsOutputSettings": { "HlsSettings": { "StandardHlsSettings": { "M3u8Settings": {} } }, "NameModifier": "_2" } } } ] } ], "TimecodeConfig": { "Source": "EMBEDDED" } } }
Output:
The output repeats back the contents of the JSON file, plus the following values. All parameters are ordered alphabetically.
ARN
for the channel. The last part of the ARN is the unique channel ID.EgressEndpoints
is blank in this example channel because it used only for PUSH inputs. When it applies it shows the addresses on MediaLive that content is pushed to.OutputGroups
,Outputs
. These show all the parameters for the output group and outputs, including those that you didn't include but that are relevant to this channel. The parameters might be empty (perhaps indicating the parameter or feature is disabled in this channel configuration) or might show the default value that will apply.LogLevel
is set to the default (DISABLED).Tags
is set to the default (null).PipelinesRunningCount
andState
show the current status of the channel.For more information, see Creating a Channel from Scratch
in the Amazon Elemental MediaLive User Guide. -
For API details, see CreateChannel
in Amazon CLI Command Reference.
-
The following code example shows how to use create-input
.
- Amazon CLI
-
To create an input
The following
create-input
example creates anHLS PULL
input by passing in a JSON file that contains the parameters that apply to this type of input. The JSON for this example input specifies two sources (addresses) to the input, in order to support redundancy in the ingest. These addresses require passwords.aws medialive create-input \ --cli-input-json
file://input-hls-pull-news.json
Contents of
input-hls-pull-news.json
:{ "Name": "local_news", "RequestId": "cli000059", "Sources": [ { "Url": "https://203.0.113.13/newschannel/anytownusa.m3u8", "Username": "examplecorp", "PasswordParam": "/medialive/examplecorp1" }, { "Url": "https://198.51.100.54/fillervideos/oceanwaves.mp4", "Username": "examplecorp", "PasswordParam": "examplecorp2" } ], "Type": "URL_PULL" }
Output:
The output repeats back the contents of the JSON file, plus the following values. All parameters are ordered alphabetically.
Arn
for the input. The last part of the ARN is the unique input ID.Attached Channels
, which is always empty for a newly created input.Destinations
, which is empty in this example because it is used only with a PUSH input.Id
for the input, the same as the ID in the ARN.MediaConnectFlows
, which is empty in this example because it is used only with an input of type MediaConnect.SecurityGroups
, which is empty in this example because it is used only with a PUSH input.State
of this input.Tags
, which is empty (the default for this parameter).For more information, see Creating an Input
in the Amazon Elemental MediaLive User Guide. -
For API details, see CreateInput
in Amazon CLI Command Reference.
-