使用 的 VODMediaPackage 範例 AWS CLI - AWS SDK 程式碼範例

文件 AWS SDK AWS 範例 SDK 儲存庫中有更多可用的 GitHub 範例。

本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。

使用 的 VODMediaPackage 範例 AWS CLI

下列程式碼範例示範如何使用 AWS Command Line Interface with MediaPackage VODWord 來執行動作和實作常見案例。

Actions 是大型程式的程式碼摘錄,必須在內容中執行。雖然 動作會示範如何呼叫個別服務函數,但您可以在其相關案例中查看內容中的動作。

每個範例都包含完整原始程式碼的連結,您可以在其中找到如何在內容中設定和執行程式碼的指示。

主題

動作

下列程式碼範例示範如何使用 create-asset

AWS CLI

若要建立資產

下列create-asset範例會在目前 AWS 帳戶中建立名為 Chicken_Asset的資產。資產擷取檔案 30sec_chicken.smil to MediaPackage。

aws mediapackage-vod create-asset \ --id chicken_asset \ --packaging-group-id hls_chicken_gp \ --source-role-arn arn:aws:iam::111122223333:role/EMP_Vod \ --source-arn arn:aws:s3::111122223333:video-bucket/A/30sec_chicken.smil

輸出:

{ "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:assets/chicken_asset", "Id":"chicken_asset", "PackagingGroupId":"hls_chicken_gp", "SourceArn":"arn:aws:s3::111122223333:video-bucket/A/30sec_chicken.smil", "SourceRoleArn":"arn:aws:iam::111122223333:role/EMP_Vod", "EgressEndpoints":[ { "PackagingConfigurationId":"New_config_1", "Url":"https://c75ea2668ab49d02bca7ae10ef31c59e.egress.mediapackage-vod.us-west-2.amazonaws.com/out/v1/6644b55df1744261ab3732a8e5cdaf07/904b06a58c7645e08d57d40d064216ac/f5b2e633ff4942228095d164c10074f3/index.m3u8" }, { "PackagingConfigurationId":"new_hls", "Url":" https://c75ea2668ab49d02bca7ae10ef31c59e.egress.mediapackage-vod.us-west-2.amazonaws.com/out/v1/6644b55df1744261ab3732a8e5cdaf07/fe8f1f00a80e424cb4f8da4095835e9e/7370ec57432343af816332356d2bd5c6/string.m3u8" } ] }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的擷取資產

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 CreateAsset

下列程式碼範例示範如何使用 create-packaging-configuration

AWS CLI

建立封裝組態

下列create-packaging-configuration範例會在名為 的封裝群組new_hls中建立名為 的封裝組態hls_chicken。此範例使用名為 之磁碟上的檔案hls_pc.json來提供詳細資訊。

aws mediapackage-vod create-packaging-configuration \ --id new_hls \ --packaging-group-id hls_chicken \ --hls-package file://hls_pc.json

hls_pc.json 的內容:

{ "HlsManifests":[ { "AdMarkers":"NONE", "IncludeIframeOnlyStream":false, "ManifestName":"string", "ProgramDateTimeIntervalSeconds":60, "RepeatExtXKey":true, "StreamSelection":{ "MaxVideoBitsPerSecond":1000, "MinVideoBitsPerSecond":0, "StreamOrder":"ORIGINAL" } } ], "SegmentDurationSeconds":6, "UseAudioRenditionGroup":false }

輸出:

{ "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-configurations/new_hls", "Id":"new_hls", "PackagingGroupId":"hls_chicken", "HlsManifests":{ "SegmentDurationSeconds":6, "UseAudioRenditionGroup":false, "HlsMarkers":[ { "AdMarkers":"NONE", "IncludeIframeOnlyStream":false, "ManifestName":"string", "ProgramDateTimeIntervalSeconds":60, "RepeatExtXKey":true, "StreamSelection":{ "MaxVideoBitsPerSecond":1000, "MinVideoBitsPerSecond":0, "StreamOrder":"ORIGINAL" } } ] } }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的建立包裝組態

下列程式碼範例示範如何使用 create-packaging-group

AWS CLI

建立封裝群組

下列create-packaging-group範例列出目前 AWS 帳戶中設定的所有封裝群組。

aws mediapackage-vod create-packaging-group \ --id hls_chicken

輸出:

{ "Arn": "arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-groups/hls_chicken", "Id": "hls_chicken" }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的建立包裝群組

下列程式碼範例示範如何使用 delete-asset

AWS CLI

若要刪除資產

下列delete-asset範例會刪除名為 的資產30sec_chicken

aws mediapackage-vod delete-asset \ --id 30sec_chicken

此命令不會產生輸出。

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的刪除資產

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DeleteAsset

下列程式碼範例示範如何使用 delete-packaging-configuration

AWS CLI

若要刪除封裝組態

下列delete-packaging-configuration範例會刪除名為 的封裝組態CMAF

aws mediapackage-vod delete-packaging-configuration \ --id CMAF

此命令不會產生輸出。

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的刪除包裝組態

下列程式碼範例示範如何使用 delete-packaging-group

AWS CLI

若要刪除封裝群組

下列delete-packaging-group範例會刪除名為 的封裝群組Dash_widevine

aws mediapackage-vod delete-packaging-group \ --id Dash_widevine

此命令不會產生輸出。

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的刪除包裝群組

下列程式碼範例示範如何使用 describe-asset

AWS CLI

描述資產

下列describe-asset範例顯示名為 之資產的所有詳細資訊30sec_chicken

aws mediapackage-vod describe-asset \ --id 30sec_chicken

輸出:

{ "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:assets/30sec_chicken", "Id":"30sec_chicken", "PackagingGroupId":"Packaging_group_1", "SourceArn":"arn:aws:s3::111122223333:video-bucket/A/30sec_chicken.smil", "SourceRoleArn":"arn:aws:iam::111122223333:role/EMP_Vod", "EgressEndpoints":[ { "PackagingConfigurationId":"DASH", "Url":"https://a5f46a44118ba3e3724ef39ef532e701.egress.mediapackage-vod.us-west-2.amazonaws.com/out/v1/aad7962c569946119c2d5a691be5663c/66c25aff456d463aae0855172b3beb27/4ddfda6da17c4c279a1b8401cba31892/index.mpd" }, { "PackagingConfigurationId":"HLS", "Url":"https://a5f46a44118ba3e3724ef39ef532e701.egress.mediapackage-vod.us-west-2.amazonaws.com/out/v1/aad7962c569946119c2d5a691be5663c/6e5bf286a3414254a2bf0d22ae148d7e/06b5875b4d004c3cbdc4da2dc4d14638/index.m3u8" }, { "PackagingConfigurationId":"CMAF", "Url":"https://a5f46a44118ba3e3724ef39ef532e701.egress.mediapackage-vod.us-west-2.amazonaws.com/out/v1/aad7962c569946119c2d5a691be5663c/628fb5d8d89e4702958b020af27fde0e/05eb062214064238ad6330a443aff7f7/index.m3u8" } ] }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的檢視資產詳細資訊

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 DescribeAsset

下列程式碼範例示範如何使用 describe-packaging-configuration

AWS CLI

描述封裝組態

下列describe-packaging-configuration範例顯示名為 的封裝組態的所有詳細資訊DASH

aws mediapackage-vod describe-packaging-configuration \ --id DASH

輸出:

{ "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-configurations/DASH", "Id":"DASH", "PackagingGroupId":"Packaging_group_1", "DashPackage":[ { "SegmentDurationSeconds":"2" }, { "DashManifests":{ "ManifestName":"index", "MinBufferTimeSeconds":"30", "Profile":"NONE" } } ] }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的檢視包裝組態詳細資訊

下列程式碼範例示範如何使用 describe-packaging-group

AWS CLI

描述封裝群組

下列describe-packaging-group範例顯示名為 的封裝群組的所有詳細資訊Packaging_group_1

aws mediapackage-vod describe-packaging-group \ --id Packaging_group_1

輸出:

{ "Arn": "arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-groups/Packaging_group_1", "Id": "Packaging_group_1" }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的檢視包裝群組詳細資訊

下列程式碼範例示範如何使用 list-assets

AWS CLI

列出所有資產

下列list-assets範例列出目前 AWS 帳戶中設定的所有資產。

aws mediapackage-vod list-assets

輸出:

{ "Assets": [ "Arn": "arn:aws:mediapackage-vod:us-west-2:111122223333:assets/30sec_chicken", "Id": "30sec_chicken", "PackagingGroupId": "Packaging_group_1", "SourceArn": "arn:aws:s3::111122223333:video-bucket/A/30sec_chicken.smil", "SourceRoleArn": "arn:aws:iam::111122223333:role/EMP_Vod" ] }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的檢視資產詳細資訊

  • 如需 API 詳細資訊,請參閱 AWS CLI 命令參考中的 ListAssets

下列程式碼範例示範如何使用 list-packaging-configurations

AWS CLI

若要列出所有封裝組態

下列list-packaging-configurations範例列出在名為 的封裝群組上設定的所有封裝組態Packaging_group_1

aws mediapackage-vod list-packaging-configurations \ --packaging-group-id Packaging_group_1

輸出:

{ "PackagingConfigurations":[ { "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-configurations/CMAF", "Id":"CMAF", "PackagingGroupId":"Packaging_group_1", "CmafPackage":[ { "SegmentDurationSeconds":"2" }, { "HlsManifests":{ "AdMarkers":"NONE", "RepeatExtXKey":"False", "ManifestName":"index", "ProgramDateTimeIntervalSeconds":"0", "IncludeIframeOnlyStream":"False" } } ] }, { "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-configurations/DASH", "Id":"DASH", "PackagingGroupId":"Packaging_group_1", "DashPackage":[ { "SegmentDurationSeconds":"2" }, { "DashManifests":{ "ManifestName":"index", "MinBufferTimeSeconds":"30", "Profile":"NONE" } } ] }, { "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-configurations/HLS", "Id":"HLS", "PackagingGroupId":"Packaging_group_1", "HlsPackage":[ { "SegmentDurationSeconds":"6", "UseAudioRenditionGroup":"False" }, { "HlsManifests":{ "AdMarkers":"NONE", "RepeatExtXKey":"False", "ManifestName":"index", "ProgramDateTimeIntervalSeconds":"0", "IncludeIframeOnlyStream":"False" } } ] }, { "Arn":"arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-configurations/New_config_0_copy", "Id":"New_config_0_copy", "PackagingGroupId":"Packaging_group_1", "HlsPackage":[ { "SegmentDurationSeconds":"6", "UseAudioRenditionGroup":"False" }, { "Encryption":{ "EncryptionMethod":"AWS_128", "SpekeKeyProvider":{ "RoleArn":"arn:aws:iam:111122223333::role/SPEKERole", "Url":"https://lfgubdvs97.execute-api.us-west-2.amazonaws.com/EkeStage/copyProtection/", "SystemIds":[ "81376844-f976-481e-a84e-cc25d39b0b33" ] } } }, { "HlsManifests":{ "AdMarkers":"NONE", "RepeatExtXKey":"False", "ManifestName":"index", "ProgramDateTimeIntervalSeconds":"0", "IncludeIframeOnlyStream":"False" } } ] } ] }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的檢視包裝組態詳細資訊

下列程式碼範例示範如何使用 list-packaging-groups

AWS CLI

列出所有封裝群組

下列list-packaging-groups範例列出目前 AWS 帳戶中設定的所有封裝群組。

aws mediapackage-vod list-packaging-groups

輸出:

{ "PackagingGroups": [ { "Arn": "arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-groups/Dash_widevine", "Id": "Dash_widevine" }, { "Arn": "arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-groups/Encrypted_HLS", "Id": "Encrypted_HLS" }, { "Arn": "arn:aws:mediapackage-vod:us-west-2:111122223333:packaging-groups/Packaging_group_1", "Id": "Packaging_group_1" } ] }

如需詳細資訊,請參閱 AWS Elemental MediaPackage 使用者指南中的檢視包裝群組詳細資訊