本指南將說明 Video Stitcher API 支援的資訊清單選項功能。這樣一來,您就能自訂拼接影片資訊清單。資訊清單選項會在工作階段建立要求中設定。詳情請參閱下列資源:
事前準備
請務必熟悉 Video Stitcher API 中的入門概念和術語。詳情請參閱技術總覽。
簡介
根據預設,拼接的影片資訊清單會包含與來源影片資訊清單相同的媒體呈現。來源資訊清單可能包含多個媒體呈現版本,但並非所有播放器都能播放。舉例來說,編碼的影片可能同時包含 H.264 和 H.265 視訊轉碼器,但某裝置上的播放器可能只支援 H.264。
您可以指定要納入影片資訊清單的編解碼或位元率,藉此指定要輸出哪些影片呈現方式。
資訊清單選項
ManifestOptions
物件提供一些選項,可讓您自訂拼接的影片資訊清單。
HLS
您可以針對拼接的 HLS 影片資訊清單自訂下列項目:
- 依編解碼篩選
- 僅納入特定影片解析度
- 只納入特定的畫面更新率
- 只納入特定比特率
- 排序影片呈現方式
在後續章節中,我們假設以下為來源影片資訊清單:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=1920x1080,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=1280x720,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/hd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=400000,RESOLUTION=1920x1080,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=100000,RESOLUTION=640x360,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=200000,RESOLUTION=1280x720,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/hd/index.m3u8
依編解碼篩選
如要依編碼器篩選影片呈現,請在建立工作階段時,在選用的 manifestOptions
欄位中設定編碼器。舉例來說,如要只在拼接的資訊清單中顯示 H.264,請在 includeRenditions
陣列中設定轉碼器:
{ "manifestOptions": { "includeRenditions": [ { "codecs": "avc1.42e00a,mp4a.40.2", }, ], }, }
以下內容會顯示在拼接資訊清單中:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=1920x1080,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=1280x720,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/index.m3u8
僅納入特定影片解析度
如要依影片解析度篩選影片呈現,請在建立工作階段時,在選用的 manifestOptions
欄位中設定影片解析度。舉例來說,如果只想在拼接後的資訊清單中顯示 1920x1080
和 640x360
影片解析度,請在 includeRenditions
陣列中設定影片解析度:
{ "manifestOptions": { "includeRenditions": [ { "videoResolution": { "widthPixels": 1920, "heightPixels": 1080, }, }, { "videoResolution": { "widthPixels": 640, "heightPixels": 360, }, }, ], }, }
以下內容會顯示在拼接資訊清單中:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=1920x1080,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=400000,RESOLUTION=1920x1080,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=100000,RESOLUTION=640x360,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/sd/index.m3u8
只納入特定的畫面更新率
如要依據影格速率篩選影片呈現方式,請在建立工作階段時,在選用的 manifestOptions
欄位中設定影格速率。舉例來說,如果您只想在拼接後的資訊清單中顯示 25.0
影格速率,請在 includeRenditions
陣列中設定影格速率:
{ "manifestOptions": { "includeRenditions": [ { "frameRate": 25.0 }, ], }, }
以下內容會顯示在拼接資訊清單中:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=1920x1080,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=1280x720,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/hd/index.m3u8
只納入特定比特率
如要依據位元率篩選影片呈現方式,請在建立工作階段時,在選用的 manifestOptions
欄位中設定位元率。舉例來說,如果只想在拼接資訊清單中顯示兩個位元率,請在 includeRenditions
陣列中設定位元率:
{ "manifestOptions": { "includeRenditions": [ { "bitrateBps": 150000, }, { "bitrateBps": 440000, }, ], }, }
以下內容會顯示在拼接資訊清單中:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=1920x1080,CODECS="avc1.42e00a,mp4a.40.2"
h264/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2"
h264/index.m3u8
依位元率排序
部分播放器可能會對影片呈現順序較為敏感。您可以將影片呈現方式的順序設為 ascending
或 descending
,如下所示:
{ "manifestOptions": { "bitrateOrder": "ascending", }, }
以下內容會顯示在拼接資訊清單中:
#EXTM3U
#EXT-X-STREAM-INF:BANDWIDTH=100000,RESOLUTION=640x360,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=200000,RESOLUTION=1280x720,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/hd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=1280x720,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/hd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=400000,RESOLUTION=1920x1080,CODECS="hvc1.1.4.L126.B0,mp4a.40.2,FRAME-RATE=50.000"
h265/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=1920x1080,CODECS="avc1.42e00a,mp4a.40.2,FRAME-RATE=25.000"
h264/fhd/index.m3u8
DASH
您可以為拼接的 DASH 影片資訊清單自訂下列項目:
- 依編解碼篩選
- 僅納入特定影片解析度
- 只納入特定的畫面更新率
- 只納入特定比特率
- 排序影片呈現方式
在後續章節中,我們假設以下為來源影片資訊清單:
<Period id="0" start="PT33160.000S">
<AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720">
<Representation mimeType="video/mp4" id="640x360-h264" codecs="avc1.64001E" width="640" height="360" startWithSAP="1" bandwidth="150000" frameRate="25/1">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h264" codecs="avc1.64001E" width="1280" height="720" startWithSAP="1" bandwidth="240000" frameRate="25/1">
...
</Representation>
<Representation mimeType="video/mp4" id="640x360-h265" codecs="hvc1.1.4.L126.B0" width="640" height="360" startWithSAP="1" bandwidth="100000" frameRate="50/1">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h265" codecs="hvc1.1.4.L126.B0" width="1280" height="720" startWithSAP="1" bandwidth="200000" frameRate="50/1">
...
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true">
<Representation mimeType="audio/mp4" id="640x360-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
<Representation mimeType="audio/mp4" id="1280x720-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
</AdaptationSet>
</Period>
依編解碼篩選
如要依編碼器篩選影片呈現,請在建立工作階段時,在選用的 manifestOptions
欄位中設定編碼器。舉例來說,如要只在拼接的資訊清單中顯示 H.264,請在 includeRenditions
陣列中設定轉碼器:
{ "manifestOptions": { "includeRenditions": [ { "codecs": "hvc1.1.4.L126.B0", }, ], }, }
以下內容會顯示在拼接資訊清單中:
<Period id="0" start="PT33160.000S">
<AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720">
<Representation mimeType="video/mp4" id="640x360-h265" codecs="hvc1.1.4.L126.B0" width="640" height="360" startWithSAP="1" bandwidth="100000" frameRate="50/1">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h265" codecs="hvc1.1.4.L126.B0" width="1280" height="720" startWithSAP="1" bandwidth="200000" frameRate="50/1">
...
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true">
<Representation mimeType="audio/mp4" id="640x360-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
<Representation mimeType="audio/mp4" id="1280x720-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
</AdaptationSet>
</Period>
僅納入特定影片解析度
如要依影片解析度篩選影片呈現,請在建立工作階段時,在選用的 manifestOptions
欄位中設定影片解析度。舉例來說,如要在拼接後的資訊清單中只顯示 640x360
影片解析度,請在 includeRenditions
陣列中設定影片解析度:
{ "manifestOptions": { "includeRenditions": [ { "videoResolution": { "widthPixels": 640, "heightPixels": 360, }, }, ], }, }
以下內容會顯示在拼接資訊清單中:
<Period id="0" start="PT33160.000S">
<AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720">
<Representation mimeType="video/mp4" id="640x360-h264" codecs="avc1.64001E" width="640" height="360" startWithSAP="1" bandwidth="150000" frameRate="25/1">
...
</Representation>
<Representation mimeType="video/mp4" id="640x360-h265" codecs="hvc1.1.4.L126.B0" width="640" height="360" startWithSAP="1" bandwidth="100000" frameRate="50/1">
...
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true">
<Representation mimeType="audio/mp4" id="640x360-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
<Representation mimeType="audio/mp4" id="1280x720-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
</AdaptationSet>
</Period>
只納入特定的畫面更新率
如要依據影格速率篩選影片呈現方式,請在建立工作階段時,在選用的 manifestOptions
欄位中設定影格速率。舉例來說,如要在拼接後的資訊清單中只顯示 25.0
影格速率,請在 includeRenditions
陣列中設定影格速率:
{ "manifestOptions": { "includeRenditions": [ { "frameRate": 25.0 }, ], }, }
以下內容會顯示在拼接資訊清單中:
<Period id="0" start="PT33160.000S">
<AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720">
<Representation mimeType="video/mp4" id="640x360-h264" codecs="avc1.64001E" width="640" height="360" startWithSAP="1" bandwidth="150000" frameRate="25/1">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h264" codecs="avc1.64001E" width="1280" height="720" startWithSAP="1" bandwidth="240000" frameRate="25/1">
...
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true">
<Representation mimeType="audio/mp4" id="640x360-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
<Representation mimeType="audio/mp4" id="1280x720-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
</AdaptationSet>
</Period>
包含特定位元率
如要依據位元率篩選影片呈現方式,請在建立工作階段時,在選用的 manifestOptions
欄位中設定位元率。舉例來說,如果只想在拼接資訊清單中顯示兩個位元率,請在 includeRenditions
陣列中設定位元率:
{ "manifestOptions": { "includeRenditions": [ { "bitrateBps": 150000, }, { "bitrateBps": 240000, }, ], }, }
以下內容會顯示在拼接資訊清單中:
<Period id="0" start="PT33160.000S">
<AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720">
<Representation mimeType="video/mp4" id="640x360-h264" codecs="avc1.64001E" width="640" height="360" startWithSAP="1" bandwidth="150000" frameRate="25/1">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h264" codecs="avc1.64001E" width="1280" height="720" startWithSAP="1" bandwidth="240000" frameRate="25/1">
...
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true">
<Representation mimeType="audio/mp4" id="640x360-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
<Representation mimeType="audio/mp4" id="1280x720-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
</AdaptationSet>
</Period>
依位元率排序
部分播放器可能會對影片呈現順序較為敏感。您可以將影片呈現方式的順序設為 ascending
或 descending
,如下所示:
{ "manifestOptions": { "bitrateOrder": "descending", }, }
以下內容會顯示在拼接資訊清單中:
<Period id="0" start="PT33160.000S">
<AdaptationSet segmentAlignment="true" maxWidth="1280" maxHeight="720">
<Representation mimeType="video/mp4" id="1280x720-h264" codecs="avc1.64001E" width="1280" height="720" startWithSAP="1" bandwidth="240000" frameRate="25/1">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h265" codecs="hvc1.1.4.L126.B0" width="1280" height="720" startWithSAP="1" bandwidth="200000" frameRate="50/1">
...
</Representation>
<Representation mimeType="video/mp4" id="640x360-h264" codecs="avc1.64001E" width="640" height="360" startWithSAP="1" bandwidth="150000" frameRate="25/1">
...
</Representation>
<Representation mimeType="video/mp4" id="640x360-h265" codecs="hvc1.1.4.L126.B0" width="640" height="360" startWithSAP="1" bandwidth="100000" frameRate="50/1">
...
</Representation>
</AdaptationSet>
<AdaptationSet segmentAlignment="true">
<Representation mimeType="audio/mp4" id="640x360-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
<Representation mimeType="audio/mp4" id="1280x720-audio" codecs="mp4a.40.2" audioSamplingRate="44100" startWithSAP="1" bandwidth="48472">
...
</Representation>
</AdaptationSet>
</Period>