本指南介绍了 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"
h264/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2"
h264/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=1280x720,CODECS="avc1.42e00a,mp4a.40.2"
h264/hd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=400000,RESOLUTION=1920x1080,CODECS="hvc1.1.4.L126.B0,mp4a.40.2"
h264/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=100000,RESOLUTION=640x360,CODECS="hvc1.1.4.L126.B0,mp4a.40.2"
h264/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=200000,RESOLUTION=1280x720,CODECS="hvc1.1.4.L126.B0,mp4a.40.2"
h264/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"
h264/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2"
h264/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=1280x720,CODECS="avc1.42e00a,mp4a.40.2"
h264/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"
h264/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=150000,RESOLUTION=640x360,CODECS="avc1.42e00a,mp4a.40.2"
h264/sd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=200000,RESOLUTION=1280x720,CODECS="hvc1.1.4.L126.B0,mp4a.40.2"
h264/hd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=240000,RESOLUTION=1280x720,CODECS="avc1.42e00a,mp4a.40.2"
h264/hd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=400000,RESOLUTION=1920x1080,CODECS="hvc1.1.4.L126.B0,mp4a.40.2"
h264/fhd/index.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=440000,RESOLUTION=1920x1080,CODECS="avc1.42e00a,mp4a.40.2"
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">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h264" codecs="avc1.64001E" width="1280" height="720" startWithSAP="1" bandwidth="240000">
...
</Representation>
<Representation mimeType="video/mp4" id="640x360-h265" codecs="hvc1.1.4.L126.B0" width="640" height="360" startWithSAP="1" bandwidth="100000">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h265" codecs="hvc1.1.4.L126.B0" width="1280" height="720" startWithSAP="1" bandwidth="200000">
...
</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">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h265" codecs="hvc1.1.4.L126.B0" width="1280" height="720" startWithSAP="1" bandwidth="200000">
...
</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">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h264" codecs="avc1.64001E" width="1280" height="720" startWithSAP="1" bandwidth="240000">
...
</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">
...
</Representation>
<Representation mimeType="video/mp4" id="1280x720-h265" codecs="hvc1.1.4.L126.B0" width="1280" height="720" startWithSAP="1" bandwidth="200000">
...
</Representation>
<Representation mimeType="video/mp4" id="640x360-h264" codecs="avc1.64001E" width="640" height="360" startWithSAP="1" bandwidth="150000">
...
</Representation>
<Representation mimeType="video/mp4" id="640x360-h265" codecs="hvc1.1.4.L126.B0" width="640" height="360" startWithSAP="1" bandwidth="100000">
...
</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>