MediaTailor Ad insertionの基本的な設定をAWS CLIでやってみた

MediaTailor Ad insertionの基本的な設定をAWS CLIでやってみた

Channel assembly機能と混在しているサブコマンド群の中からAd insertion機能用のサブコマンドを把握すること、またConfigurationの作成と更新をどちらもPut系のサブコマンドで行う点に注意しましょう。

Clock Icon2024.6.30
facebook logohatena logotwitter logo

はじめに

清水です。AWSのリニアチャネルアセンブリとパーソナライズされた広告挿入サービスであるAWS Elemental MediaTailorのAd insertion(広告挿入)機能について、基本的な操作をAWS CLIでやってみました。なお「基本的な操作」については以下ブログエントリで扱ったような、プリロール広告付きVOD動画配信を行うまでの操作を想定しています。

MediaTailor Ad insertionのベースとなる Configuration リソースに対して、その表示や作成、更新や削除をしていくようなイメージですね。またセッションログ設定に関しても扱います。

MediaTailor Ad insertionのAWS CLIでの操作はaws mediatailorコマンドを使用することとなりますが、このサブコマンド群がChannel assembly機能と独立しておらず、どちらもaws mediatailorではじまります。そのため、Ad insertion用のサブコマンドをきちんと把握することがひとつのポイントかと思います。また、リソースの作成と変更がaws mediatailor put-playback-configurationの1つのサブコマンドにまとめられている点にも注意しましょう。(てっきりcreate-playback-configurationupdate-playback-configurationのように2種類のサブコマンドがあるかと思っていました。)セッションログ設定については専用のサブコマンドが準備されています。

なお、本エントリでは以下のAWS CLI環境で動作確認を行いました。

% aws --version
aws-cli/2.16.11 Python/3.11.8 Darwin/22.6.0 exe/x86_64

MediaTailor Ad insertion用のサブコマンドの確認

MediaTailro Ad insertionの操作用コマンドを実行する前に、まずはAWS CLIのmediatailorコマンドのうちAd insertion機能用のサブコマンドを確認しておきましょう。

AWS CLI Command ReferenceのページをみてみるとMediaTailorについてのコマンドは1つだけ、mediatailorが存在していることが確認できます。(以下、本エントリでは動作検証にAWS CLI version 2を使用したため、参照先についてもversion 2のページをリンクとして掲載します。)

2024/06/20現在44個のサブコマンドがありますが、以下のように(1) Ad insertion機能用サブコマンド、(2) Channel assembly機能用サブコマンド、(3) タグ操作用サブコマンドの3つにわけることができます。それぞれ一覧にしてみました。

Ad insertion機能用サブコマンド

Ad insertion機能用のサブコマンドは以下の9つです。

Channel Assembly機能用サブコマンド

以下の26個がChannel Assembly機能用のサブコマンドです。

タグ操作用サブコマンド

以下の3つはタグ操作用のサブコマンドです。MediaTailorでタグ付けがサポートされているリソースは、Ad insertionではConfigurations、Channel assemblyではChannelsSourceLocationsVodSourcesとなっています。(Tagging AWS Elemental MediaTailor resources - AWS Elemental MediaTailor

Configurationの表示(ListとGet)

aws mediatailorコマンドの機能ごとのサブコマンドについて整理ができたところで、実際にAd insertion機能用のサブコマンドを確認していきましょう。まずはリソースの参照系のサブコマンドです。aws mediatailor list-playback-configurationsサブコマンド、ならびにaws mediatailor get-playback-configurationサブコマンドを使用します。

一覧表示のlist-playback-configurations

aws mediatailor list-playback-configurationsサブコマンドはオプションなしで実行可能です。

% aws mediatailor list-playback-configurations

以下のような実行結果となります。存在しているConfigurationsリソースを一覧表示するかたちですね。

% aws mediatailor list-playback-configurations
{
    "Items": [
        {
            "AdDecisionServerUrl": "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/111111111/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpremidpost&cmsid=496&vid=short_onecue&correlator=[avail.random]",
            "AvailSuppression": {
                "Mode": "OFF"
            },
            "Bumper": {},
            "CdnConfiguration": {},
            "DashConfiguration": {
                "ManifestEndpointPrefix": "https://e726xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/MyTestCampaign/",
                "MpdLocation": "EMT_DEFAULT",
                "OriginManifestType": "MULTI_PERIOD"
            },
            "HlsConfiguration": {
                "ManifestEndpointPrefix": "https://e726xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/MyTestCampaign/"
            },
            "InsertionMode": "STITCHED_ONLY",
            "LivePreRollConfiguration": {},
            "ManifestProcessingRules": {
                "AdMarkerPassthrough": {
                    "Enabled": false
                }
            },
            "Name": "MyTestCampaign",
            "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/MyTestCampaign",
            "PlaybackEndpointPrefix": "https://e726xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
            "SessionInitializationEndpointPrefix": "https://e726xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/MyTestCampaign/",
            "Tags": {},
            "VideoContentSourceUrl": "https://ab29xxxxxxxxxxxxxxxxxxxxxxxxxxxx.egress.mediapackage-vod.ap-northeast-1.amazonaws.com/out/v1/edf3xxxxxxxxxxxxxxxxxxxxxxxxxxxx/4efexxxxxxxxxxxxxxxxxxxxxxxxxxxx/abaexxxxxxxxxxxxxxxxxxxxxxxxxxxx"
        },
        {
            "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
            "AvailSuppression": {
                "FillPolicy": "FULL_AVAIL_ONLY",
                "Mode": "OFF"
            },
            "Bumper": {},
            "CdnConfiguration": {},
            "ConfigurationAliases": {},
            "DashConfiguration": {
                "ManifestEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-2/",
                "MpdLocation": "EMT_DEFAULT",
                "OriginManifestType": "MULTI_PERIOD"
            },
            "HlsConfiguration": {
                "ManifestEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-2/"
            },
            "InsertionMode": "STITCHED_ONLY",
            "LivePreRollConfiguration": {},
            "ManifestProcessingRules": {
                "AdMarkerPassthrough": {
                    "Enabled": false
                }
            },
            "Name": "vod-preroll-2",
            "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-2",
            "PlaybackEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
            "SessionInitializationEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-2/",
            "Tags": {},
            "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
        }
    ]
}

ConfigurationのNameのみ一覧表示したいといった場合は、--query "Items[*].Name"などのオプションをつけましょう。

% aws mediatailor list-playback-configurations \
  --query "Items[*].Name"
[
    "MyTestCampaign",
    "vod-preroll-2"
]

個別表示のget-playback-configuration

aws mediatailor get-playback-configurationサブコマンドは単一のConfigurationの情報を表示します。--nameオプションでConfigurationのNameを指定します。

% aws mediatailor get-playback-configuration \
  --name <value>

出力から得られる情報はlist-playback-configurationsサブコマンドと同等のようです。複数のconfigurationの情報が欲しい場合はlist-playback-configurationsサブコマンド、Configuration Nameがわかっていて単一のConfigurationの情報のみが欲しい場合はget-playback-configurationサブコマンドと使いわけましょう。

% aws mediatailor get-playback-configuration \
  --name vod-preroll-2
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "FillPolicy": "FULL_AVAIL_ONLY",
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {},
    "ConfigurationAliases": {},
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-2/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-2/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-2",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-2",
    "PlaybackEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://d25cxxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-2/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

Configurationの作成(Put)

リソース参照系のコマンドが確認できました。続いてはリソース作成のコマンドです。

存在しないcreate-playback-configuration

リソース作成についてはcreateではじまるサブコマンド(API)があるのかな、と思いきやcreate-palyback-configurationというサブコマンドはありません。Command Referenceのaws mediatailor put-playback-configurationサブコマンドのページを確認するとわかるのですが、このput-playback-configurationサブコマンドを使用してconfigurationリソースを作成する(Creates a playback configuration.)、とのことです。

新規作成はput-playback-configuration

aws mediatailor put-playback-configurationサブコマンド、Command ReferenceのSynopsisからは--nameオプションのみ必須かなとも思ったのですが、--nameに加えて--ad-decision-server-url--video-content-source-urlは必須なようです。マネジメントコンソールでのConfigurationリソース作成時と同じですね。

% aws mediatailor put-playback-configuration \
  --name <value> \
  --ad-decision-server-url <value> \
  --video-content-source-url <value>

以下が実際の実行例です。put-playback-configurationの実行の前にlist-playback-configurationsで既存のConfigurationリソースを確認しておきます。2つ存在している状態ですね。

% aws mediatailor list-playback-configurations \
  --query "Items[*].Name"
[
    "MyTestCampaign",
    "vod-preroll-2"
]

いざ、put-playback-configurationを実行して新規にConfigurationリソースを作成します。サブコマンド実行のレスポンスとして作成したConfigurationリソースの情報が返ります。

% aws mediatailor put-playback-configuration \
  --name vod-preroll-cli \
  --ad-decision-server-url "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml" \
  --video-content-source-url "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {},
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

もういちどlist-playback-configurationsでConfigurationの一覧を確認しておきます。3つになっていますね。

% aws mediatailor list-playback-configurations
[
    "MyTestCampaign",
    "vod-preroll-2",
    "vod-preroll-cli"
]

put-playback-configuration--nameオプションのほかに--ad-decision-server-url--video-content-source-urlも必須である、と先ほど述べました。これらを指定しなかった場合についても確認しておきましょう。

まずは--ad-decision-server-urlを指定しなかった場合です。AdDecisionServerUrlを指定せよ、とエラーとなっていしまいますね。

% aws mediatailor put-playback-configuration \
  --name vod-preroll-cli-no-ads \
  --video-content-source-url "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"

An error occurred (BadRequestException) when calling the PutPlaybackConfiguration operation: AdDecisionServerUrl must be provided

続いては--video-content-source-urlを指定しなかった場合です。こちらもエラーとなり、VideoContentSourceUrlをするようメッセージが返されます。

% aws mediatailor put-playback-configuration \
  --name vod-preroll-cli-no-source \
  --ad-decision-server-url "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml"

An error occurred (BadRequestException) when calling the PutPlaybackConfiguration operation: VideoContentSourceUrl must be provided

Configurationの更新(Put)

Configurationリソースの作成についてはput-playback-configurationサブコマンドで実行することが確認できました。Configurationリソースの更新についても、同じくこのput-playback-configurationサブコマンドで実行します。(更新専用のupdate-playback-configurationといったサブコマンドはありません。)

注意点として、コマンド実行時には変更したい項目のみをオプションで指定するのではなく、その他の変更対象ではない項目についてもオプションで指定する必要があります。

設定変更もput-playback-configuration

実際に確認してみましょう。先ほどput-playback-configurationサブコマンドで作成したConfigurationに、CDN設定を加える設定更新をしてみます。以下のように各オプションを指定してサブコマンドを実行します。

% aws mediatailor put-playback-configuration \
  --name <value> \
  --ad-decision-server-url <value> \
  --video-content-source-url <value> \
  --cdn-configuration <value>

--cdn-configurationオプションはAdSegmentUrlPrefix=string,ContentSegmentUrlPrefix=stringのように指定します。実際に実行して確認してみましょう。まずはCDN設定を加える前のConfigurationの出力をget-playback-configurationサブコマンドで確認しておきます。

% aws mediatailor get-playback-configuration \
  --name vod-preroll-cli
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {},
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

CDN設定を加えたい、ということで以下のようにput-playback-configurationサブコマンドに--name--cdn-configurationオプションのみを指定した場合、エラーとなってしまいます。

% aws mediatailor put-playback-configuration \
  --name vod-preroll-cli \
  --cdn-configuration AdSegmentUrlPrefix="https://d2p0zy0qeyjyuw.cloudfront.net",ContentSegmentUrlPrefix="https://d2p0zy0qeyjyuw.cloudfront.net"

An error occurred (BadRequestException) when calling the PutPlaybackConfiguration operation: AdDecisionServerUrl must be provided

今回の実行例では、--name--cdn-configurationに加え、 --ad-decision-server-url--video-content-source-urlが必須のオプションとなります。

% aws mediatailor put-playback-configuration \
  --name vod-preroll-cli \
  --ad-decision-server-url "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml" \
  --cdn-configuration AdSegmentUrlPrefix="https://d2p0xxxxxxxxxx.cloudfront.net",ContentSegmentUrlPrefix="https://d2p0xxxxxxxxxx.cloudfront.net"

An error occurred (BadRequestException) when calling the PutPlaybackConfiguration operation: VideoContentSourceUrl must be provided

以下がすべての必須オプションをそろえてput-playback-configurationサブコマンドを実行した例です。レスポンスとして設定内容が返り、CdnConfigurationが設定されていることが確認できますね。

% aws mediatailor put-playback-configuration \
  --name vod-preroll-cli \
  --ad-decision-server-url "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml" \
  --video-content-source-url "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com" \
  --cdn-configuration AdSegmentUrlPrefix="https://d2p0xxxxxxxxxx.cloudfront.net",ContentSegmentUrlPrefix="https://d2p0xxxxxxxxxx.cloudfront.net"
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {
        "AdSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net",
        "ContentSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net"
    },
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

CDN設定を加えるためのput-playback-configurationサブコマンド実行後、もう一度get-playback-configurationサブコマンドでConfiguration情報を確認してみます。きちんとCDN設定CdnConfigurationが更新されていますね。

% aws mediatailor get-playback-configuration \
  --name vod-preroll-cli
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {
        "AdSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net",
        "ContentSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net"
    },
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

セッションログ設定

Configurationリソースの設定変更についてはリソース作成と同様にput-playback-configurationサブコマンドを利用、その際には変更しない項目についてもオプションで指定する必要がある、という使い方でした。さてConfigurationリソースに関する設定項目のうち、セッションログ設定についてはこの規則が当てはまりません。put-playback-configurationサブコマンドのオプションで指定するかたちではなく、専用のサブコマンドconfigure-logs-for-playback-configurationで設定を行います。

なおセッションログについてはCloudWatch Logsに出力され、MediaTailor Configuration側でこのCloudWatch Logsに送信するログ出力の量を割合で指定可能というものでした。詳細は以下ブログエントリを参照ください。

セッションログ設定専用のconfigure-logs-for-playback-configuration

aws mediatailor configure-logs-for-playback-configurationサブコマンドについては以下の書式で使用します。オプションとして、--playback-configuration-nameでConfigurationのNameを、また--percent-enabledでCloudWatch Logsに送信するログの量の割合を指定します。

% aws mediatailor configure-logs-for-playback-configuration \
  --playback-configuration-name <value> \
  --percent-enabled <value>

以下、実際の実行例です。先ほどput-playback-configurationサブコマンドで作成ならびに設定変更を行ったConfigurationですが、ログについては設定していない状況でした。get-playback-configurationサブコマンドで確認しても、ログに関する項目はありませんね。

% aws mediatailor get-playback-configuration \
  --name vod-preroll-cli
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {
        "AdSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net",
        "ContentSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net"
    },
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

configure-logs-for-playback-configurationサブコマンドでセッションログ出力を設定してみます。ログ出力の割合は100 (%)としました。コマンドの返り値で設定項目が確認できますね。

% aws mediatailor configure-logs-for-playback-configuration \
  --playback-configuration-name vod-preroll-cli \
  --percent-enabled 100
{
    "PercentEnabled": 100,
    "PlaybackConfigurationName": "vod-preroll-cli"
}

get-playback-configurationサブコマンドでも確認してみましょう。"LogConfiguration"という項目が追加されていることがわかります。

% aws mediatailor get-playback-configuration \
  --name vod-preroll-cli
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {
        "AdSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net",
        "ContentSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net"
    },
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "LogConfiguration": {
        "PercentEnabled": 100
    },
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

ログ出力割合の変更についても確認してみます。まずは60 (%)にしてみます。

% aws mediatailor configure-logs-for-playback-configuration \
  --playback-configuration-name vod-preroll-cli \
  --percent-enabled 60
{
    "PercentEnabled": 60,
    "PlaybackConfigurationName": "vod-preroll-cli"
}

get-playback-configurationサブコマンドの実行結果でも、ログ出力の割合が変更されていることが確認できます。

% aws mediatailor get-playback-configuration \
  --name vod-preroll-cli
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {
        "AdSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net",
        "ContentSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net"
    },
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "LogConfiguration": {
        "PercentEnabled": 60
    },
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

セッションログ出力を無効(オフ)にする場合は、出力する割合を0 (%)に設定するという認識です。こちらも実行してみます。

% aws mediatailor configure-logs-for-playback-configuration \
  --playback-configuration-name vod-preroll-cli \
  --percent-enabled 0
{
    "PercentEnabled": 0,
    "PlaybackConfigurationName": "vod-preroll-cli"
}
% aws mediatailor get-playback-configuration \
  --name vod-preroll-cli
{
    "AdDecisionServerUrl": "https://ad-decision-xxxxxxxx.s3.ap-northeast-1.amazonaws.com/ads/static-vast-demo.xml",
    "AvailSuppression": {
        "Mode": "OFF"
    },
    "Bumper": {},
    "CdnConfiguration": {
        "AdSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net",
        "ContentSegmentUrlPrefix": "https://d2p0xxxxxxxxxx.cloudfront.net"
    },
    "DashConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/dash/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
        "MpdLocation": "EMT_DEFAULT",
        "OriginManifestType": "MULTI_PERIOD"
    },
    "HlsConfiguration": {
        "ManifestEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/master/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/"
    },
    "InsertionMode": "STITCHED_ONLY",
    "LivePreRollConfiguration": {},
    "LogConfiguration": {
        "PercentEnabled": 0
    },
    "ManifestProcessingRules": {
        "AdMarkerPassthrough": {
            "Enabled": false
        }
    },
    "Name": "vod-preroll-cli",
    "PlaybackConfigurationArn": "arn:aws:mediatailor:us-west-2:123456789012:playbackConfiguration/vod-preroll-cli",
    "PlaybackEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com",
    "SessionInitializationEndpointPrefix": "https://f5d9xxxxxxxxxxxxxxxxxxxxxxxxxxxx.mediatailor.us-west-2.amazonaws.com/v1/session/75e6xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/vod-preroll-cli/",
    "Tags": {},
    "VideoContentSourceUrl": "https://content-source-xxxxxxxx.s3.ap-northeast-1.amazonaws.com"
}

Configurationの削除(Delete)

Configurationリソースの表示、新規作成と更新、そしてセッションログ設定の各サブコマンドについて確認してきました。最後にConfigurationリソースの削除について確認しましょう。Configurationリソースの削除はdelete-playback-configurationサブコマンドで行います。

削除はdelete-playback-configuration

aws mediatailor delete-playback-configurationの書式は以下となります。--nameオプションでConfigurationリソースのNameのみ指定するかたちですね。

% aws mediatailor delete-playback-configuration \
  --name <value>

以下が実行例となります。コマンド実行時の返り値は特にありませんので、実行前後でlist-playback-configurationsサブコマンドなどを使って確認するようにしましょう。

% aws mediatailor list-playback-configurations \
  --query "Items[*].Name"
[
    "MyTestCampaign",
    "vod-preroll-2",
    "vod-preroll-cli"
]

% aws mediatailor delete-playback-configuration \
  --name vod-preroll-cli

% aws mediatailor list-playback-configurations \
  --query "Items[*].Name"
[
    "MyTestCampaign",
    "vod-preroll-2"
]

まとめ

AWS Elemental MediaTailor Ad insertion(広告挿入)機能の基本的な操作をAWS CLIでやってみました。aws mediatailorコマンドの一覧を確認するとサブコマンドが少し多くびっくりしますが、Channel assembly機能のサブコマンドも含まれています。まずはAd insertionの操作用サブコマンドを確認しましょう。(AWSサービスによって、例えばMediaPackageやAmazon IVSのように機能ごとコマンド自体がわかれているものもあります。対して、今回のMediaTailorやMediaLive、さらにEC2など1つのコマンド内に複数機能のサブコマンド群が含まれているものも多いですね。)

Ad insertionでは操作対象のリソースがConfigurationと(今回は扱いませんでしたが)Prefetch schedule、そしてログ設定用サブコマンドというかたちで、AWS CLIでの操作も基本をおさえておけばシンプルに操作が実現できるかと思います。またConfigurationについては新規作成と設定変更、いずれもputではじまるサブコマンドではじまる点が要注意かなと思いました。(aws mediatailorコマンドでも、Channel assemblyのChannelリソースなどはcreateupdateではじまるサブコマンドが準備されています。リソースによって異なる点が興味深いですね。)

この記事をシェアする

facebook logohatena logotwitter logo

© Classmethod, Inc. All rights reserved.