

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

# 資訊清單篩選
<a name="manifest-filtering"></a>

透過資訊清單篩選， 會根據您在附加至播放請求的查詢中指定的參數， AWS Elemental MediaPackage 動態產生用戶端資訊清單。這可讓您執行像是限制瀏覽者存取高級 4K HEVC 內容，或鎖定特定裝置類型和音訊取樣率範圍等操作，全都來自單一端點。先前，您必須設定多個端點才能完成此行為。MediaPackage 現在提供經濟實惠的方式，可在相同的端點上動態產生不同的用戶端資訊清單。

## 使用資訊清單篩選條件
<a name="working-with-manifest-filters"></a>

當您使用資訊清單篩選條件時，產生的資訊清單只會包含符合您在查詢中指定之特性音訊和影片串流。如果沒有使用資訊清單篩選條件，則所有內嵌串流都會出現在端點輸出串流中。但如果您已經為端點設定串流篩選條件，例如最小影片位元率，此情況則屬例外。在這種情況下，資訊清單篩選條件會套用在串流篩選條件之後，這可能會扭曲您的輸出，因此不建議使用。

資訊清單篩選可用於 MediaPackage 支援的所有端點類型：
+ Apple HLS
+ DASH-ISO
+ Microsoft Smooth Streaming
+ CMAF

若要使用資訊清單篩選，請將`aws.manifestfilter`查詢參數附加到 MediaPackage 的播放請求。MediaPackage 會評估查詢，並根據這些查詢參數提供用戶端資訊清單。資訊清單查詢*不*區分大小寫，字數上限為 1024 個字元。如果查詢格式錯誤，或者沒有符合查詢參數的串流，MediaPackage 會傳回不完整或空白的資訊清單。如需查詢語法，請參閱下一節。

**注意**  
如果您使用的是 Apple HLS 或 CMAF 端點，則適用特殊條件。如需這些條件的資訊，請參閱 [HLS 和 CMAF 資訊清單的特殊條件](#special-conditions-HLS-CMAF-manifests)。

**查詢語法**  
基本查詢參數是 `aws.manifestfilter`，後接可選參數名稱和值對。若要建構查詢，請附加`?aws.manifestfilter=`至 MediaPackage 端點 URL 的結尾，後面接著參數名稱和值。如需所有可用參數的清單，請參閱 [資訊清單篩選條件查詢參數](#manifest-filter-query-parameters)。

Apple HLS 篩選條件查詢看起來可能像這樣：

`https://example-mediapackage-endpoint.mediapackage.us-west-2.amazonaws.com/out/v1/examplemediapackage/index.m3u8?aws.manifestfilter=audio_sample_rate:0-44100;video_bitrate:0-2147483647;video_codec:h265;audio_language:fr,en-US,de`

下表列出查詢語法。


| 查詢字串元件 | Description | 
| --- | --- | 
| ? | 標記查詢開頭的限制字元。 | 
| aws.manifestfilter= | 基本查詢，後接名稱和值對組成的參數。如需所有可用參數的清單，請參閱 [資訊清單篩選條件查詢參數](#manifest-filter-query-parameters)。 | 
| : | 用於將參數名稱與值相關聯。例如 parameter\$1name:value。 | 
| ; | 在包含多個參數的查詢中分隔參數。例如 parameter1\$1name:value;parameter2\$1name:minValue-maxValue。 | 
| , | 分隔值的清單。例如 parameter\$1name:value1,value2,value3。列表中以逗號分隔的值代表 OR 關係。 | 
| - | 用於定義參數的最小值 - 最大值範圍。例如 audio\$1sample\$1rate:0-44100。在範圍中使用數值時，數值會包括在範圍定義中。這代表串流必須大於或等於最小值，並且小於或等於最大值。使用範圍時，最小值和最大值為必要屬性。支援的範圍值為 0 - 2147483647。 | 

**注意**  
如果您使用 Amazon CloudFront 做為 CDN，您可能需要設定其他組態。如需詳細資訊，請參閱 [Configure cache behavior for all endpoints ](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/live-streaming.html#live-streaming-with-mediapackage-create-cache-behavior)(設定所有端點的快取行為)。

## 資訊清單篩選條件查詢參數
<a name="manifest-filter-query-parameters"></a>

MediaPackage 支援下列查詢參數。


| Category | 名稱 | 描述 | 範例 | 
| --- | --- | --- | --- | 
| 音訊 | audio\$1bitrate |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=audio\$1bitrate:0-2147483647 | 
| 音訊 | audio\$1channels |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=audio\$1channels:1-8 | 
| 音訊 | audio\$1codec |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=audio\$1codec:AACL,AC-3 | 
| 音訊 | audio\$1language |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=audio\$1language:fr,en-US,de | 
| 音訊 | audio\$1sample\$1rate |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=audio\$1sample\$1rate:0-44100 | 
| 字幕 | subtitle\$1language |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=subtitle\$1language:en-US, hi | 
| 影片 | trickplay\$1height |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=trickplay\$1height:200-1200 | 
| 影片 | trickplay\$1type |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=trickplay\$1type:iframe | 
| 影片 | video\$1bitrate |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=video\$1bitrate:0-2147483647 | 
| 影片 | video\$1codec |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=video\$1codec:h264 | 
| 影片 | video\$1dynamic\$1range |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=video\$1dynamic\$1range:hdr10 | 
| 影片 | video\$1framerate |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=video\$1framerate:23.976-30 | 
| 影片 | video\$1height |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/mediapackage/latest/ug/manifest-filtering.html)  | stream.mpd?aws.manifestfilter=video\$1height:720-1080 | 

## 資訊清單篩選範例
<a name="manifest-filtering-examples"></a>

這些是資訊清單篩選範例。

**Example 1：針對支援 AVC 和 44.1k 音訊取樣率的播放器**  
觀眾正在只能支援 AVC 和 44.1k 音頻採樣率的設備上播放內容。您可以設置 `video_codec` 和 `audio_sample_rate` 篩選掉不符合這些需求的串流。

`?aws.manifestfilter=audio_sample_rate:0-44100;video_codec:h264`

**Example 2：限制 4k HEVC 內容**  
您的 4K HEVC 串流為 15 Mbps，而所有其他串流都低於 9 Mbps。若要從串流集排除 4K 串流，請設定每秒 9,000,000 位元的閾值，以篩選出較高的位元率。

`?aws.manifestfilter=video_bitrate:0-9000000`

**Example 3：包含每秒 23.976 至 30 個影格之間的視訊**  
若只要包含特定影格速率範圍內的視訊，請使用 `video_framerate`。此參數接受具有最多三個選用小數值的浮點數。

`?aws.manifestfilter=video_framerate:23.976-30`

## HLS 和 CMAF 資訊清單的特殊條件
<a name="special-conditions-HLS-CMAF-manifests"></a>

如果您使用 HLS 或 CMAF 資訊清單，則適用這些特殊條件。
+ 對於 HLS 資訊清單，我們強烈建議您使用音訊轉譯群組，以避免將篩選出音訊串流的多工影片串流移除。如需有關轉譯群組的詳細資訊，請參閱[中的轉譯群組參考 AWS Elemental MediaPackage](rendition-groups.md)。
+ 在 HLS 和 CMAF 資訊清單中，音訊取樣率不會發出訊號，因此要以視覺方式檢查此設定的原始清單或篩選清單並不容易。若要驗證音訊取樣率，請檢查編碼器級別和輸出級別的音訊取樣率。
+ 在 HLS 和 CMAF 資訊清單中，變體的 `BANDWIDTH` 屬性會將音訊軌道的頻寬與影片軌道相關聯，可能是影片軌道多工處理相關聯，或是由影片軌道所參考的音訊轉譯軌道相關聯。因此，您無法以視覺化方式檢查原始和篩選的資訊清單，以確認`video_bitrate`篩選條件是否正常運作。若要驗證篩選條件，請在編碼器級別和輸出級別檢查影片位元率。
+ 對於 HLS 和 CMAF 資訊清單，請求參數附加到位元率播放列表或段，將會導致 HTTP 400 錯誤。

## 錯誤情況
<a name="error-conditions-and-handling"></a>

如果資訊清單或區段包含無效或未知的查詢參數，某些播放裝置會傳回錯誤。以下是 MediaPackage 可以處理的查詢參數：
+ `m`
+ `start`
+ `end`
+ `aws.manifestfilter`
+ `aws.drmsettings`

如果您有未列出的查詢參數，請使用 Amazon CloudFront 等 CDN 移除不必要的參數。如需詳細資訊，請參閱《*Amazon CloudFront 開發人員指南*》中的[根據查詢字串參數快取內容](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/QueryStringParameters.html)。

下表包含其他常見的錯誤條件。


****  

| 錯誤條件 | 範例 | HTTP 狀態碼 | 
| --- | --- | --- | 
| 找不到清單參數，也不是限制清單的一部分 | ?aws.manifestfilter=audio\$1language:dahlia | 200 | 
| 串流中只有字幕串流存在 | ?aws.manifestfilter=audio\$1sample\$1rate:0-1;video\$1bitrate=0-1 | 200 | 
| 複製篩選參數 | ?aws.manifestfilter=audio\$1sample\$1rate:0-48000;aws.manifestfilter=audio\$1sample\$1rate:0-48000 | 400 | 
| 參數無效 | ?aws.manifestfilter=donut\$1type:rhododendron | 400 | 
| 無效的範圍參數 | ?aws.manifestfilter=audio\$1sample\$1rate:300-0 | 400 | 
| 無效的範圍值 (大於 INT\$1MAX) | ?aws.manifestfilter=audio\$1sample\$1rate:0-2147483648 | 400 | 
| 格式不正確的查詢字串 | ?aws.manifestfilter=audio\$1sample\$1rate:is:0-44100 | 400 | 
| 參數字串大於 1024 個字元 | ?aws.manifestfilter=audio\$1language:abcdef.... | 400 | 
| HLS 或 CMAF 位元率資訊清單上的查詢參數 | index\$11.m3u8?aws.manifestfilter=video\$1codec:h264 | 400 | 
| 區段請求上的查詢參數 | ...\$11.[ts\$1mp4\$1vtt..]?aws.manifestfilter=video\$1codec:h264 | 400 | 
| 重複的查詢參數 | ?aws.manifestfilter=audio\$1sample\$1rate:0-48000;aws.manifestfilter=video\$1bitrate:0-1 | 400 | 
| 篩選條件的應用程式會產生空白資訊清單 (內容沒有符合查詢字串中定義的條件的資料串流) | ?aws.manifestfilter=audio\$1sample\$1rate:0-1;video\$1bitrate=0-1 | 400 | 