【やってみた】AWS Elemental MediaLiveの情報をAWS CLIで取得してみた #reinvent

【やってみた】AWS Elemental MediaLiveの情報をAWS CLIで取得してみた #reinvent

Clock Icon2017.12.31

この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。

はじめに

清水です。AWS Media Servicesの特長の1つは他のAWSサービスと同様にAWS CLIや各種SDKなどからAPIを通して利用できる点ではないでしょうか。AWS Media ServicesのAWS CLIコマンドについてはサービスリリース時から使用できることが中山(順)のエントリにてレポートされています。本エントリではAWS Elemental MediaLiveについて、実際にAWS CLIを用いて各リソースの情報取得などを行ってみたのでまとめてみます。

やってみた

AWS Elemental MediaLiveは大きく以下の3つのリソースから構成されます。

  • Input
  • Input Security Group
  • Channel

マネージメントコンソールの画面でもこちらの3つが表示されていますね。

この各リソースについて、AWS CLIを使って情報を取得していきます。まず準備として、AWS CLIを最新バージョンにアップデートしておきましょう。本エントリではmac OS Sierra上の以下の環境で検証を行いました。

 $ aws --version
aws-cli/1.14.17 Python/2.7.10 Darwin/16.7.0 botocore/1.8.21

また本エントリではAWS Elemental MediaLiveの各リソースの作成についてはマネージメントコンソールなどで行っていることを前提とし、基本的には情報の取得のみをAWS CLIで実行してみます。各リソース作成については下記のエントリなどをご参照ください。

またAWS CLIのaws medialiveの使用方法の詳細については下記のAWS CLI Command Referenceページからリンクされているドキュメントを参照しています。

Input

まずInputです。Inputに関連するのは以下の4つのコマンドですね。

  • create-input
  • delete-input
  • describe-input
  • list-inputs

このうちlist-inputsとdescribe-inputを使ってInputの情報を確認してみます。

aws medialive list-inputs

以下のようにオプション引数なしで実行しました。(出力数が多くなる場合などは引数で調整ができるようです。)

 $ aws medialive list-inputs

出力は以下のようになりました。マネージメントコンソールのInputs一覧画面で表示できる情報プラスアルファが確認できる具合ですね。

{
    "Inputs": [
        {
            "Name": "MediaLiveInput1222",
            "AttachedChannels": [
                "6607XXX"
            ],
            "Sources": [],
            "State": "ATTACHED",
            "SecurityGroups": [
                "954XXX"
            ],
            "Type": "RTMP_PUSH",
            "Id": "7036XXX",
            "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:input:7036XXX",
            "Destinations": [
                {
                    "Url": "rtmp://35.165.XXX.XXX:1935/live/myStream",
                    "Ip": "35.165.XXX.XXX",
                    "Port": "1935"
                },
                {
                    "Url": "rtmp://52.32.XXX.XXX:1935/live/myStream",
                    "Ip": "52.32.XXX.XXX",
                    "Port": "1935"
                }
            ]
        },
        {
            "Name": "MediaLive-akiba-aws-3-Input-2",
            "AttachedChannels": [
                "8778XXX"
            ],
            "Sources": [],
            "State": "ATTACHED",
            "SecurityGroups": [
                "954XXX"
            ],
            "Type": "RTMP_PUSH",
            "Id": "1360XXX",
            "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:input:1360XXX",
            "Destinations": [
                {
                    "Url": "rtmp://34.216.XXX.XXX:1935/akiba/aws",
                    "Ip": "34.216.XXX.XXX",
                    "Port": "1935"
                },
                {
                    "Url": "rtmp://35.167.XXX.XXX:1935/akiba/aws",
                    "Ip": "35.167.XXX.XXX",
                    "Port": "1935"
                }
            ]
        },
        {
            "Name": "MediaLive-akiba-aws-3-Input",
            "AttachedChannels": [],
            "Sources": [],
            "State": "DETACHED",
            "SecurityGroups": [
                "954XXX"
            ],
            "Type": "RTMP_PUSH",
            "Id": "558820",
            "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:input:558820",
            "Destinations": [
                {
                    "Url": "rtmp://34.210.XXX.XXX:1935/akiba/aws",
                    "Ip": "34.210.XXX.XXX",
                    "Port": "1935"
                },
                {
                    "Url": "rtmp://34.216.XXX.XXX:1935/akiba/aws",
                    "Ip": "34.216.XXX.XXX",
                    "Port": "1935"
                }
            ]
        }
    ]
}

以下のようにqueryオプションを使用すれば、マネージメントコンソールと同様の形式で情報をまとめられます。

 $ aws medialive list-inputs --query Inputs[].[Name,State,Id,Arn,Type,Destinations[].Url] --output text
MediaLiveInput1222      ATTACHED        7036XXX arn:aws:medialive:us-west-2:[AWS-Account-ID]:input:7036XXX   RTMP_PUSH
rtmp://35.165.XXX.XXX:1935/live/myStream  rtmp://52.32.XXX.XXX:1935/live/myStream
MediaLive-akiba-aws-3-Input-2   ATTACHED        1360XXX arn:aws:medialive:us-west-2:[AWS-Account-ID]:input:1360XXX   RTMP_PUSH
rtmp://34.216.XXX.XXX:1935/akiba/aws    rtmp://35.167.XXX.XXX:1935/akiba/aws
MediaLive-akiba-aws-3-Input     DETACHED        558820  arn:aws:medialive:us-west-2:[AWS-Account-ID]:input:558820    RTMP_PUSH
rtmp://34.210.XXX.XXX:1935/akiba/aws    rtmp://34.216.XXX.XXX:1935/akiba/aws

aws medialive describe-input

続いてliset-inputsで得られてたInputのうちの1つについて、describe-inputコマンドで詳細情報を取得してみます。InputのIDが引数として必要な点に注意します。

 $ aws medialive --describe-input --input-id <value>

結果は以下となりました。1つの要素のみですが、内容はlist-inputsの情報と同じようですね。

{
    "Name": "MediaLiveInput1222",
    "AttachedChannels": [
        "6607XXX"
    ],
    "Sources": [],
    "State": "ATTACHED",
    "SecurityGroups": [
        "954XXX"
    ],
    "Type": "RTMP_PUSH",
    "Id": "7036XXX",
    "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:input:7036XXX",
    "Destinations": [
        {
            "Url": "rtmp://35.165.XXX.XXX:1935/live/myStream",
            "Ip": "35.165.XXX.XXX",
            "Port": "1935"
        },
        {
            "Url": "rtmp://52.32.XXX.XXX:1935/live/myStream",
            "Ip": "52.32.XXX.XXX",
            "Port": "1935"
        }
    ]
}

Input Security Group

続いてInput Security GroupについてもAWS CLIで情報を取得してみます。Input Security Groupに関連するコマンドもInputと同じように以下の4つで構成されています。

  • create-input-security-group
  • delete-input-security-group
  • describe-input-security-group
  • list-input-security-group

list-input-security-groupとdescribe-input-security-groupを使用してみます。

aws medialive list-input-security-group

list-inputと同様、以下のようにオプション引数なしで実行しました。

 $ aws medialive list-input-security-groups

結果は以下のようになりました。

{
    "InputSecurityGroups": [
        {
            "WhitelistRules": [
                {
                    "Cidr": "211.2.XXX.XXX/32"
                },
                {
                    "Cidr": "59.146.XXX.XXX/32"
                }
            ],
            "Id": "4097XXX",
            "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:inputSecurityGroup:4097976"
        },
        {
            "WhitelistRules": [
                {
                    "Cidr": "0.0.0.0/0"
                }
            ],
            "Id": "954XXX",
            "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:inputSecurityGroup:954XXX"
        }
    ]
}

describe-input-security-group

続いてdescribe-input-security-groupです。実行時に以下のようにInput Security GroupのIDが必要となります。

 $ aws medialive describe-input-security-group --input-security-group-id <value>

liset-input-security-groupで得られた結果の1つ目、ID「4097XXX」を使って実行してみます。

{
    "WhitelistRules": [
        {
            "Cidr": "211.2.XXX.XXX/32"
        },
        {
            "Cidr": "59.146.XXX.XXX/32"
        }
    ],
    "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:inputSecurityGroup:4097XXX",
    "Id": "4097XXX"
}

こちらもlist-security-groupの情報と同様のようですね。

Channel

Channelについては以下の6つのコマンドが用意されています。

  • create-channel
  • delete-channel
  • describe-channel
  • list-channels
  • start-channel
  • stop-channel

まずはInput、Input Security Groupと同じようにlist-channelsとdescribe-channelコマンドで情報を取得してみます。

aws medialive list-channels

list-channlesについては、他と同様、引数なしで実行してみます。

 $ aws medialive list-channels

以下の結果が返ってきました。

{
    "Channels": [
        {
            "InputAttachments": [
                {
                    "InputId": "7036XXX",
                    "InputSettings": {
                        "AudioSelectors": [],
                        "CaptionSelectors": [
                            {
                                "SelectorSettings": {
                                    "EmbeddedSourceSettings": {
                                        "Scte20Detection": "OFF",
                                        "Source608ChannelNumber": 1,
                                        "Convert608To708": "DISABLED",
                                        "Source608TrackNumber": 1
                                    }
                                },
                                "Name": "EmbeddedSelector"
                            }
                        ],
                        "SourceEndBehavior": "CONTINUE",
                        "InputFilter": "AUTO",
                        "FilterStrength": 1,
                        "NetworkInputSettings": {
                            "ServerValidation": "CHECK_CRYPTOGRAPHY_AND_VALIDATE_NAME"
                        },
                        "DenoiseFilter": "DISABLED",
                        "DeblockFilter": "DISABLED"
                    }
                }
            ],
            "Name": "MediaLiveChanne1222",
            "RoleArn": "arn:aws:iam::[AWS-Account-ID]:role/MediaLiveAccessRole",
            "State": "IDLE",
            "EgressEndpoints": [
                {
                    "SourceIp": "34.213.XXX.XXX"
                },
                {
                    "SourceIp": "52.24.XXX.XXX"
                }
            ],
            "PipelinesRunningCount": 0,
            "Id": "6607XXX",
            "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:channel:6607XXX",
            "Destinations": [
                {
                    "Id": "destination1",
                    "Settings": [
                        {
                            "Url": "mediastoressl://g3ozdxXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                            "Username": "",
                            "PasswordParam": ""
                        },
                        {
                            "Url": "mediastoressl://toccawXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                            "Username": "",
                            "PasswordParam": ""
                        }
                    ]
                }
            ]
        },
        {
            "InputAttachments": [
                {
                    "InputId": "1360XXX",
                    "InputSettings": {
                        "AudioSelectors": [],
                        "CaptionSelectors": [],
                        "SourceEndBehavior": "CONTINUE",
                        "InputFilter": "AUTO",
                        "FilterStrength": 1,
                        "NetworkInputSettings": {
                            "ServerValidation": "CHECK_CRYPTOGRAPHY_AND_VALIDATE_NAME"
                        },
                        "DenoiseFilter": "DISABLED",
                        "DeblockFilter": "DISABLED"
                    }
                }
            ],
            "Name": "MediaLive-akiba-aws-3-Channel-2",
            "RoleArn": "arn:aws:iam::[AWS-Account-ID]:role/MediaLiveAccessRole",
            "State": "IDLE",
            "EgressEndpoints": [
                {
                    "SourceIp": "34.216.XXX.XXX"
                },
                {
                    "SourceIp": "34.216.XXX.XXX"
                }
            ],
            "PipelinesRunningCount": 0,
            "Id": "8778XXX",
            "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:channel:8778XXX",
            "Destinations": [
                {
                    "Id": "destination1",
                    "Settings": [
                        {
                            "Url": "https://626e3c9eXXXXXXXX.mediapackage.us-west-2.amazonaws.com/in/v1/d8232a64b3c44537XXXXXXXXXXXXXXXX/channel",
                            "Username": "fe00529a9c534d35XXXXXXXXXXXXXXXX",
                            "PasswordParam": "/medialive/MediaPackage-akiba-aws-3-ChannelA"
                        },
                        {
                            "Url": "https://f31c86aeXXXXXXXX.mediapackage.us-west-2.amazonaws.com/in/v1/51e6700ec11240dcXXXXXXXXXXXXXXXX/channel",
                            "Username": "ab5cc8d414cb4133XXXXXXXXXXXXXXXX",
                            "PasswordParam": "/medialive/MediaPackage-akiba-aws-3-ChannelB"
                        }
                    ]
                }
            ]
        }
    ]
}

マネージメントコンソールの一覧画面と同様の情報にするため、--queryオプションで情報を絞ってみます。

 $ aws medialive list-channels --query Channels[].[Name,State,Id,Arn,InputAttachments[].InputId] --output text
MediaLiveChanne1222     IDLE    6607XXX arn:aws:medialive:us-west-2:[AWS-Account-ID]:channel:6607XXX
7036XXX
MediaLive-akiba-aws-3-Channel-2 IDLE    8778XXX arn:aws:medialive:us-west-2:[AWS-Account-ID]:channel:8778XXX
1360XXX

aws medialive describe-channel

describe-channelのコマンドは以下の形式となります。他と同様、ChannelのIDが必要です。

 $ aws medialive describe-channel --channel-id <value>

ChannelのIDを元に、describe-channelコマンドを実行してみます。以下の結果が返ってきました。Input、Input security groupと違いlistの情報と同様ではなく、Encoder設定などより詳細情報が得られました。

 $ aws medialive describe-channel --channel-id 6607XXX
{
    "InputAttachments": [
        {
            "InputId": "7036XXX",
            "InputSettings": {
                "AudioSelectors": [],
                "CaptionSelectors": [
                    {
                        "SelectorSettings": {
                            "EmbeddedSourceSettings": {
                                "Scte20Detection": "OFF",
                                "Source608ChannelNumber": 1,
                                "Convert608To708": "DISABLED",
                                "Source608TrackNumber": 1
                            }
                        },
                        "Name": "EmbeddedSelector"
                    }
                ],
                "SourceEndBehavior": "CONTINUE",
                "InputFilter": "AUTO",
                "FilterStrength": 1,
                "NetworkInputSettings": {
                    "ServerValidation": "CHECK_CRYPTOGRAPHY_AND_VALIDATE_NAME"
                },
                "DenoiseFilter": "DISABLED",
                "DeblockFilter": "DISABLED"
            }
        }
    ],
    "Name": "MediaLiveChanne1222",
    "RoleArn": "arn:aws:iam::[AWS-Account-ID]:role/MediaLiveAccessRole",
    "PipelinesRunningCount": 0,
    "EgressEndpoints": [
        {
            "SourceIp": "34.213.XXX.XXX"
        },
        {
            "SourceIp": "52.24.XXX.XXX"
        }
    ],
    "State": "IDLE",
    "EncoderSettings": {
        "TimecodeConfig": {
            "Source": "EMBEDDED"
        },
        "OutputGroups": [
            {
                "OutputGroupSettings": {
                    "HlsGroupSettings": {
                        "TimedMetadataId3Frame": "PRIV",
                        "CaptionLanguageMappings": [],
                        "Destination": {
                            "DestinationRefId": "destination1"
                        },
                        "IvSource": "FOLLOWS_SEGMENT_NUMBER",
                        "IndexNSegments": 10,
                        "InputLossAction": "EMIT_OUTPUT",
                        "ManifestDurationFormat": "INTEGER",
                        "CodecSpecification": "RFC_4281",
                        "IvInManifest": "INCLUDE",
                        "TimedMetadataId3Period": 10,
                        "ProgramDateTimePeriod": 600,
                        "SegmentLength": 6,
                        "CaptionLanguageSetting": "OMIT",
                        "ProgramDateTime": "EXCLUDE",
                        "HlsCdnSettings": {
                            "HlsWebdavSettings": {
                                "NumRetries": 10,
                                "ConnectionRetryInterval": 1,
                                "HttpTransferMode": "NON_CHUNKED",
                                "FilecacheDuration": 300,
                                "RestartDelay": 15
                            }
                        },
                        "TsFileMode": "SEGMENTED_FILES",
                        "StreamInfResolution": "INCLUDE",
                        "ClientCache": "ENABLED",
                        "AdMarkers": [],
                        "KeepSegments": 21,
                        "SegmentationMode": "USE_SEGMENT_DURATION",
                        "OutputSelection": "MANIFESTS_AND_SEGMENTS",
                        "ManifestCompression": "NONE",
                        "DirectoryStructure": "SINGLE_DIRECTORY",
                        "Mode": "LIVE"
                    }
                },
                "Outputs": [
                    {
                        "VideoDescriptionName": "video_1080p30",
                        "AudioDescriptionNames": [
                            "audio_1"
                        ],
                        "CaptionDescriptionNames": [],
                        "OutputSettings": {
                            "HlsOutputSettings": {
                                "NameModifier": "_1080p30",
                                "HlsSettings": {
                                    "StandardHlsSettings": {
                                        "M3u8Settings": {
                                            "PcrControl": "PCR_EVERY_PES_PACKET",
                                            "TimedMetadataBehavior": "NO_PASSTHROUGH",
                                            "PmtPid": "480",
                                            "Scte35Pid": "500",
                                            "VideoPid": "481",
                                            "ProgramNum": 1,
                                            "AudioPids": "492-498",
                                            "AudioFramesPerPes": 4,
                                            "EcmPid": "8182",
                                            "Scte35Behavior": "NO_PASSTHROUGH"
                                        },
                                        "AudioRenditionSets": "PROGRAM_AUDIO"
                                    }
                                }
                            }
                        }
                    },
                    {
                        "VideoDescriptionName": "video_720p30",
                        "AudioDescriptionNames": [
                            "audio_2"
                        ],
                        "CaptionDescriptionNames": [],
                        "OutputSettings": {
                            "HlsOutputSettings": {
                                "NameModifier": "_720p30",
                                "HlsSettings": {
                                    "StandardHlsSettings": {
                                        "M3u8Settings": {
                                            "PcrControl": "PCR_EVERY_PES_PACKET",
                                            "TimedMetadataBehavior": "NO_PASSTHROUGH",
                                            "PmtPid": "480",
                                            "Scte35Pid": "500",
                                            "VideoPid": "481",
                                            "ProgramNum": 1,
                                            "AudioPids": "492-498",
                                            "AudioFramesPerPes": 4,
                                            "EcmPid": "8182",
                                            "Scte35Behavior": "NO_PASSTHROUGH"
                                        },
                                        "AudioRenditionSets": "PROGRAM_AUDIO"
                                    }
                                }
                            }
                        }
                    },
                    {
                        "VideoDescriptionName": "video_480p30",
                        "AudioDescriptionNames": [
                            "audio_za9dzo"
                        ],
                        "CaptionDescriptionNames": [],
                        "OutputSettings": {
                            "HlsOutputSettings": {
                                "NameModifier": "_480p30",
                                "HlsSettings": {
                                    "StandardHlsSettings": {
                                        "M3u8Settings": {
                                            "PcrControl": "PCR_EVERY_PES_PACKET",
                                            "TimedMetadataBehavior": "NO_PASSTHROUGH",
                                            "PmtPid": "480",
                                            "Scte35Pid": "500",
                                            "VideoPid": "481",
                                            "ProgramNum": 1,
                                            "AudioPids": "492-498",
                                            "AudioFramesPerPes": 4,
                                            "EcmPid": "8182",
                                            "Scte35Behavior": "NO_PASSTHROUGH"
                                        },
                                        "AudioRenditionSets": "PROGRAM_AUDIO"
                                    }
                                }
                            }
                        }
                    },
                    {
                        "VideoDescriptionName": "video_240p30",
                        "AudioDescriptionNames": [
                            "audio_40bxb2"
                        ],
                        "CaptionDescriptionNames": [],
                        "OutputSettings": {
                            "HlsOutputSettings": {
                                "NameModifier": "_240p30",
                                "HlsSettings": {
                                    "StandardHlsSettings": {
                                        "M3u8Settings": {
                                            "PcrControl": "PCR_EVERY_PES_PACKET",
                                            "TimedMetadataBehavior": "NO_PASSTHROUGH",
                                            "PmtPid": "480",
                                            "Scte35Pid": "500",
                                            "VideoPid": "481",
                                            "ProgramNum": 1,
                                            "AudioPids": "492-498",
                                            "AudioFramesPerPes": 4,
                                            "EcmPid": "8182",
                                            "Scte35Behavior": "NO_PASSTHROUGH"
                                        },
                                        "AudioRenditionSets": "PROGRAM_AUDIO"
                                    }
                                }
                            }
                        }
                    }
                ],
                "Name": "HD"
            }
        ],
        "CaptionDescriptions": [],
        "VideoDescriptions": [
            {
                "CodecSettings": {
                    "H264Settings": {
                        "Syntax": "DEFAULT",
                        "FramerateNumerator": 30,
                        "Profile": "HIGH",
                        "GopSize": 60,
                        "AfdSignaling": "NONE",
                        "FramerateControl": "SPECIFIED",
                        "ColorMetadata": "INSERT",
                        "FlickerAq": "ENABLED",
                        "LookAheadRateControl": "HIGH",
                        "FramerateDenominator": 1,
                        "Bitrate": 5000000,
                        "TimecodeInsertion": "DISABLED",
                        "NumRefFrames": 3,
                        "EntropyEncoding": "CABAC",
                        "GopSizeUnits": "FRAMES",
                        "Level": "H264_LEVEL_AUTO",
                        "GopBReference": "ENABLED",
                        "AdaptiveQuantization": "HIGH",
                        "GopNumBFrames": 3,
                        "ScanType": "PROGRESSIVE",
                        "ParControl": "INITIALIZE_FROM_SOURCE",
                        "Slices": 1,
                        "SpatialAq": "ENABLED",
                        "TemporalAq": "ENABLED",
                        "RateControlMode": "CBR",
                        "SceneChangeDetect": "ENABLED",
                        "GopClosedCadence": 1
                    }
                },
                "Name": "video_1080p30",
                "Sharpness": 50,
                "Height": 1080,
                "Width": 1920,
                "ScalingBehavior": "DEFAULT",
                "RespondToAfd": "NONE"
            },
            {
                "CodecSettings": {
                    "H264Settings": {
                        "Syntax": "DEFAULT",
                        "FramerateNumerator": 30,
                        "Profile": "HIGH",
                        "GopSize": 60,
                        "AfdSignaling": "NONE",
                        "FramerateControl": "SPECIFIED",
                        "ColorMetadata": "INSERT",
                        "FlickerAq": "ENABLED",
                        "LookAheadRateControl": "HIGH",
                        "FramerateDenominator": 1,
                        "Bitrate": 3000000,
                        "TimecodeInsertion": "DISABLED",
                        "NumRefFrames": 3,
                        "EntropyEncoding": "CABAC",
                        "GopSizeUnits": "FRAMES",
                        "Level": "H264_LEVEL_AUTO",
                        "GopBReference": "ENABLED",
                        "AdaptiveQuantization": "HIGH",
                        "GopNumBFrames": 3,
                        "ScanType": "PROGRESSIVE",
                        "ParControl": "INITIALIZE_FROM_SOURCE",
                        "Slices": 1,
                        "SpatialAq": "ENABLED",
                        "TemporalAq": "ENABLED",
                        "RateControlMode": "CBR",
                        "SceneChangeDetect": "ENABLED",
                        "GopClosedCadence": 1
                    }
                },
                "Name": "video_720p30",
                "Sharpness": 100,
                "Height": 720,
                "Width": 1280,
                "ScalingBehavior": "DEFAULT",
                "RespondToAfd": "NONE"
            },
            {
                "CodecSettings": {
                    "H264Settings": {
                        "TemporalAq": "ENABLED",
                        "Syntax": "DEFAULT",
                        "FramerateNumerator": 30,
                        "Profile": "MAIN",
                        "GopSize": 60,
                        "AfdSignaling": "NONE",
                        "FramerateControl": "SPECIFIED",
                        "ColorMetadata": "INSERT",
                        "FlickerAq": "ENABLED",
                        "LookAheadRateControl": "HIGH",
                        "FramerateDenominator": 1,
                        "Bitrate": 1500000,
                        "TimecodeInsertion": "DISABLED",
                        "NumRefFrames": 3,
                        "EntropyEncoding": "CABAC",
                        "GopSizeUnits": "FRAMES",
                        "Level": "H264_LEVEL_AUTO",
                        "GopBReference": "ENABLED",
                        "ParDenominator": 3,
                        "AdaptiveQuantization": "HIGH",
                        "GopNumBFrames": 3,
                        "ScanType": "PROGRESSIVE",
                        "ParControl": "SPECIFIED",
                        "Slices": 1,
                        "SpatialAq": "ENABLED",
                        "ParNumerator": 4,
                        "RateControlMode": "CBR",
                        "SceneChangeDetect": "ENABLED",
                        "GopClosedCadence": 1
                    }
                },
                "Name": "video_480p30",
                "Sharpness": 100,
                "Height": 480,
                "Width": 640,
                "ScalingBehavior": "STRETCH_TO_OUTPUT",
                "RespondToAfd": "NONE"
            },
            {
                "CodecSettings": {
                    "H264Settings": {
                        "TemporalAq": "ENABLED",
                        "Syntax": "DEFAULT",
                        "FramerateNumerator": 30,
                        "Profile": "MAIN",
                        "GopSize": 60,
                        "AfdSignaling": "NONE",
                        "FramerateControl": "SPECIFIED",
                        "ColorMetadata": "INSERT",
                        "FlickerAq": "ENABLED",
                        "LookAheadRateControl": "HIGH",
                        "FramerateDenominator": 1,
                        "Bitrate": 750000,
                        "TimecodeInsertion": "DISABLED",
                        "NumRefFrames": 3,
                        "EntropyEncoding": "CABAC",
                        "GopSizeUnits": "FRAMES",
                        "Level": "H264_LEVEL_AUTO",
                        "GopBReference": "ENABLED",
                        "ParDenominator": 3,
                        "AdaptiveQuantization": "HIGH",
                        "GopNumBFrames": 3,
                        "ScanType": "PROGRESSIVE",
                        "ParControl": "SPECIFIED",
                        "Slices": 1,
                        "SpatialAq": "ENABLED",
                        "ParNumerator": 4,
                        "RateControlMode": "CBR",
                        "SceneChangeDetect": "ENABLED",
                        "GopClosedCadence": 1
                    }
                },
                "Name": "video_240p30",
                "Sharpness": 100,
                "Height": 240,
                "Width": 320,
                "ScalingBehavior": "STRETCH_TO_OUTPUT",
                "RespondToAfd": "NONE"
            }
        ],
        "AudioDescriptions": [
            {
                "CodecSettings": {
                    "AacSettings": {
                        "Profile": "LC",
                        "InputType": "NORMAL",
                        "RateControlMode": "CBR",
                        "Spec": "MPEG4",
                        "SampleRate": 48000,
                        "Bitrate": 128000,
                        "CodingMode": "CODING_MODE_2_0",
                        "RawFormat": "NONE"
                    }
                },
                "Name": "audio_1",
                "LanguageCodeControl": "FOLLOW_INPUT",
                "AudioSelectorName": "Default",
                "AudioTypeControl": "FOLLOW_INPUT"
            },
            {
                "CodecSettings": {
                    "AacSettings": {
                        "Profile": "LC",
                        "InputType": "NORMAL",
                        "RateControlMode": "CBR",
                        "Spec": "MPEG4",
                        "SampleRate": 48000,
                        "Bitrate": 128000,
                        "CodingMode": "CODING_MODE_2_0",
                        "RawFormat": "NONE"
                    }
                },
                "LanguageCodeControl": "FOLLOW_INPUT",
                "AudioTypeControl": "FOLLOW_INPUT",
                "Name": "audio_2"
            },
            {
                "CodecSettings": {
                    "AacSettings": {
                        "Profile": "LC",
                        "InputType": "NORMAL",
                        "RateControlMode": "CBR",
                        "Spec": "MPEG4",
                        "SampleRate": 48000,
                        "Bitrate": 192000,
                        "CodingMode": "CODING_MODE_2_0",
                        "RawFormat": "NONE"
                    }
                },
                "LanguageCodeControl": "FOLLOW_INPUT",
                "AudioTypeControl": "FOLLOW_INPUT",
                "Name": "audio_za9dzo"
            },
            {
                "CodecSettings": {
                    "AacSettings": {
                        "Profile": "LC",
                        "InputType": "NORMAL",
                        "RateControlMode": "CBR",
                        "Spec": "MPEG4",
                        "SampleRate": 48000,
                        "Bitrate": 192000,
                        "CodingMode": "CODING_MODE_2_0",
                        "RawFormat": "NONE"
                    }
                },
                "LanguageCodeControl": "FOLLOW_INPUT",
                "AudioTypeControl": "FOLLOW_INPUT",
                "Name": "audio_40bxb2"
            }
        ]
    },
    "Id": "6607XXX",
    "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:channel:6607XXX",
    "Destinations": [
        {
            "Id": "destination1",
            "Settings": [
                {
                    "Url": "mediastoressl://g3ozdxXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                    "Username": "",
                    "PasswordParam": ""
                },
                {
                    "Url": "mediastoressl://toccawXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                    "Username": "",
                    "PasswordParam": ""
                }
            ]
        }
    ]
}

aws medialive start-channel / aws medialive stop-channel

続いてChannelについてはstart/stop操作を実行するコマンドも用意されています。形式としては以下のようにどちらも引数でChannelのIDを必要とします。

 $ aws medialive start-channel --channel-id <value>
 $ aws medialive stop-channel --channel-id <value>

それでは停止の状態からstart-channelコマンドを実行してみます。 まずは以下のようにdescribe-channelコマンドに--queryオプションを付け、State情報を抽出します。IDLE状態ですね。

 $ aws medialive describe-channel --channel-id 6607XXX --query [Name,State,Id]
[
    "MediaLiveChanne1222",
    "IDLE",
    "6607XXX"
]

そしてstart-channelコマンドを実行します。

 $ aws medialive start-channel --channel-id 6607XXX

実行後、describe-channelと同様と思われる情報が返ってきます。情報が多すぎるので一部(EncoderSettings部分)を割愛した情報を以下に提示します。

{
    "InputAttachments": [
        {
            "InputId": "7036XXX",
            "InputSettings": {
                "AudioSelectors": [],
                "CaptionSelectors": [
                    {
                        "SelectorSettings": {
                            "EmbeddedSourceSettings": {
                                "Scte20Detection": "OFF",
                                "Source608ChannelNumber": 1,
                                "Convert608To708": "DISABLED",
                                "Source608TrackNumber": 1
                            }
                        },
                        "Name": "EmbeddedSelector"
                    }
                ],
                "SourceEndBehavior": "CONTINUE",
                "InputFilter": "AUTO",
                "FilterStrength": 1,
                "NetworkInputSettings": {
                    "ServerValidation": "CHECK_CRYPTOGRAPHY_AND_VALIDATE_NAME"
                },
                "DenoiseFilter": "DISABLED",
                "DeblockFilter": "DISABLED"
            }
        }
    ],
    "Name": "MediaLiveChanne1222",
    "RoleArn": "arn:aws:iam::[AWS-Account-ID]:role/MediaLiveAccessRole",
    "PipelinesRunningCount": 0,
    "EgressEndpoints": [
        {
            "SourceIp": "34.213.XXX.XXX"
        },
        {
            "SourceIp": "52.24.XXX.XXX"
        }
    ],
    "State": "STARTING",
    "EncoderSettings": {
        "割愛"
    },
    "Id": "6607XXX",
    "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:channel:6607XXX",
    "Destinations": [
        {
            "Id": "destination1",
            "Settings": [
                {
                    "Url": "mediastoressl://g3ozdxXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                    "Username": "",
                    "PasswordParam": ""
                },
                {
                    "Url": "mediastoressl://toccawXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                    "Username": "",
                    "PasswordParam": ""
                }
            ]
        }
    ]
}

以下のように、start-channelコマンド実行直後はSTARTINGの状態ですが、しばらくするとRUNNING状態となります。

 $ aws medialive describe-channel --channel-id 6607XXX --query [Name,State,Id]
[
    "MediaLiveChanne1222",
    "STARTING",
    "6607XXX"
]
 $ aws medialive describe-channel --channel-id 6607XXX --query [Name,State,Id]
[
    "MediaLiveChanne1222",
    "RUNNING",
    "6607XXX"
]

今度はこの状態からstop-channelコマンドを実行してみます。

 $ aws medialive stop-channel --channel-id 6607XXX

start-channelと同様、Channelの詳細情報が返ってきます。

{
    "InputAttachments": [
        {
            "InputId": "7036XXX",
            "InputSettings": {
                "AudioSelectors": [],
                "CaptionSelectors": [
                    {
                        "SelectorSettings": {
                            "EmbeddedSourceSettings": {
                                "Scte20Detection": "OFF",
                                "Source608ChannelNumber": 1,
                                "Convert608To708": "DISABLED",
                                "Source608TrackNumber": 1
                            }
                        },
                        "Name": "EmbeddedSelector"
                    }
                ],
                "SourceEndBehavior": "CONTINUE",
                "InputFilter": "AUTO",
                "FilterStrength": 1,
                "NetworkInputSettings": {
                    "ServerValidation": "CHECK_CRYPTOGRAPHY_AND_VALIDATE_NAME"
                },
                "DenoiseFilter": "DISABLED",
                "DeblockFilter": "DISABLED"
            }
        }
    ],
    "Name": "MediaLiveChanne1222",
    "RoleArn": "arn:aws:iam::[AWS-Account-ID]:role/MediaLiveAccessRole",
    "PipelinesRunningCount": 2,
    "EgressEndpoints": [
        {
            "SourceIp": "34.213.XXX.XXX"
        },
        {
            "SourceIp": "52.24.XXX.XXX"
        }
    ],
    "State": "STOPPING",
    "EncoderSettings": {
        "割愛"
    },
    "Id": "6607XXX",
    "Arn": "arn:aws:medialive:us-west-2:[AWS-Account-ID]:channel:6607XXX",
    "Destinations": [
        {
            "Id": "destination1",
            "Settings": [
                {
                    "Url": "mediastoressl://g3ozdxXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                    "Username": "",
                    "PasswordParam": ""
                },
                {
                    "Url": "mediastoressl://toccawXXXXXXXX.data.mediastore.us-west-2.amazonaws.com/live/myStream",
                    "Username": "",
                    "PasswordParam": ""
                }
            ]
        }
    ]
}

stop-channelコマンド実行直後はSTOPPING状態ですが、しばらくするとIDLE状態になりました。

 $ aws medialive describe-channel --channel-id 6607XXX --query [Name,State,Id]
[
    "MediaLiveChanne1222",
    "STOPPING",
    "6607XXX"
]
 $ aws medialive describe-channel --channel-id 6607XXX --query [Name,State,Id]
[
    "MediaLiveChanne1222",
    "IDLE",
    "6607XXX"
]

まとめ

AWS CLIを使ってAWS Elemental MediaLiveの各リソースの情報取得、またChannelのstart/stop動作を行ってみました。情報取得については、Input、Input Security Group、Channelともlistコマンドとdescribeコマンドが用意されており、同様の使用感で使えるのではないでしょうか。Channelについてのみdescribeすることでlist以上の詳細な情報が出力されることが確認できました。AWS CLIを使うことで例えばマネージメントコンソールの画面上での確認のみではなく、CLI出力のテキストとして差分を確認するなど様々な利用方法が考えられると思います。今回触れられなかったcreate、delete操作についても今後検証してみたいと思います。

Share this article

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.