使用动态打包器筛选清单Filter your manifests using Dynamic Packager

将自适应比特率流内容传送到设备时,有时需要发布多个版本的清单来适应特定的设备功能或可用网络带宽。When you're delivering adaptive bitrate streaming content to devices, you sometimes need to publish multiple versions of a manifest to target specific device capabilities or available network bandwidth. 使用动态打包器可以指定筛选器,用于即时筛选出特定的编解码器、分辨率、比特率和音频轨迹组合。The Dynamic Packager lets you specify filters which can filter out specific codecs, resolutions, bitrates, and audio track combinations on-the-fly. 这种筛选消除了创建多个副本的需要。This filtering removes the need to create multiple copies. 只需使用一组根据目标设备(iOS、Android、SmartTV 或浏览器)和网络功能(高带宽、移动或低带宽方案)配置的一组特定筛选器发布新的 URL。You simply need to publish a new URL with a specific set of filters configured to your target devices (iOS, Android, SmartTV, or browsers) and the network capabilities (high-bandwidth, mobile, or low-bandwidth scenarios). 在这种情况下,客户端可以通过查询字符串处理内容流(通过指定可用的资产筛选器或帐户筛选器),并使用筛选器来流式传输流的特定部分。In this case, clients can manipulate the streaming of your content through the query string (by specifying available Asset filters or Account filters) and use filters to stream specific sections of a stream.

某些传送方案要求确保客户无法访问特定的轨迹。Some delivery scenarios require that you make sure a customer can't access specific tracks. 例如,你可能不想要将包含 HD 轨迹的清单发布到特定的订户层。For example, maybe you don't want to publish a manifest that contains HD tracks to a specific subscriber tier. 或者,你可能想要删除特定的自适应比特率 (ABR) 轨迹,以降低传送到不会受益于更多轨迹的特定设备的成本。Or, maybe you want to remove specific adaptive bitrate (ABR) tracks to reduce cost of delivery to a specific device that wouldn't benefit from the additional tracks. 在这种情况下,可以在创建时将预先创建的筛选器列表关联到流定位符In this case, you could associate a list of pre-created filters with your Streaming Locator on creation. 于是,客户端将无法处理内容的流式传输方式,因为传输方式由流定位符定义。Clients then can't manipulate how the content is streamed because it's defined by the Streaming Locator.

可以通过指定针对流定位符的筛选器,以及客户端在 URL 中指定的其他设备特定筛选器,来组合筛选。You can combine filtering through specifying filters on Streaming Locator + additional device-specific filters that your client specifies in the URL. 这种组合可以有效地限制其他轨迹,例如元数据或事件流、音频语言,或描述性的音频轨迹。This combination is useful to restrict additional tracks like metadata or event streams, audio languages, or descriptive audio tracks.

针对流指定不同筛选器的功能提供了一种强大的动态清单处理解决方案用于定位目标设备的多用例方案。This ability to specify different filters on your stream provides a powerful Dynamic Manifest manipulation solution to target multiple use-case scenarios for your target devices. 本主题介绍与动态清单相关的概念,并提供可以使用此功能的示例方案。This topic explains concepts related to Dynamic Manifests and gives examples of scenarios in which you can use this feature.

备注

动态清单不会更改资产和该资产的默认清单。Dynamic Manifests don't change the asset and the default manifest for that asset.

清单概述Overview of manifests

Azure 媒体服务支持 HLS、MPEG DASH 和平滑流式处理协议。Azure Media Services supports HLS, MPEG DASH, and Smooth Streaming protocols. 作为动态打包的一部分,流式处理客户端清单(HLS Master 播放列表、DASH 媒体演播描述 [MPD] 和平滑流式处理)将会根据 URL 中的格式选择器动态生成。As part of Dynamic Packaging, the streaming client manifests (HLS Master Playlist, DASH Media Presentation Description [MPD], and Smooth Streaming) are dynamically generated based on the format selector in the URL. 有关详细信息,请参阅常用按需工作流中的传送协议。For more information, see the delivery protocols in Common on-demand workflow.

获取并检查清单文件Get and examine manifest files

指定筛选器轨迹属性条件的列表,应该根据该列表将流(直播或点播视频 [VOD])的轨迹包含到动态创建的清单中。You specify a list of filter track property conditions based on which tracks of your stream (live or video on-demand [VOD]) should be included in a dynamically created manifest. 若要获取并检查轨迹的属性,必须先加载平滑流式处理清单。To get and examine the properties of the tracks, you have to load the Smooth Streaming manifest first.

使用 .NET 上传、编码和流式传输文件教程介绍了如何使用 .NET 创建流式处理 URL。The Upload, encode, and stream files with .NET tutorial shows you how to build the streaming URLs with .NET. 如果运行应用,某个 URL 将指向平滑流式处理清单:https://amsaccount-cne21.streaming.media.chinacloudapi.cn/00000000-0000-0000-0000-0000000000000/ignite.ism/manifestIf you run the app, one of the URLs points to the Smooth Streaming manifest: https://amsaccount-cne21.streaming.media.chinacloudapi.cn/00000000-0000-0000-0000-0000000000000/ignite.ism/manifest.
请复制该 URL 并将其粘贴到浏览器的地址栏中。Copy and paste the URL into the address bar of a browser. 随后将下载文件。The file will be downloaded. 可以在任何文本编辑器中将其打开。You can open it in any text editor.

有关 REST 示例,请参阅使用 REST 上传、编码和流式传输文件For a REST example, see Upload, encode, and stream files with REST.

监视视频流的比特率Monitor the bitrate of a video stream

可以使用 Azure Media Player 演示页监视视频流的比特率。You can use the Azure Media Player demo page to monitor the bitrate of a video stream. 演示页在“诊断”选项卡中显示诊断信息: The demo page displays diagnostics info on the Diagnostics tab:

Azure Media Player 诊断

示例:在查询字符串中包含筛选器的 URLExamples: URLs with filters in query string

可将筛选器应用到 ABR 流式处理协议:HLS、MPEG-DASH 和平滑流式处理。You can apply filters to ABR streaming protocols: HLS, MPEG-DASH, and Smooth Streaming. 下表显示了一些包含筛选器的 URL 示例:The following table shows some examples of URLs with filters:

协议Protocol 示例Example
HLSHLS https://amsv3account-cne21.streaming.media.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/bigbuckbunny.ism/manifest(format=m3u8-aapl,filter=myAccountFilter)
MPEG DASHMPEG DASH https://amsv3account-cne21.streaming.media.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/bigbuckbunny.ism/manifest(format=mpd-time-csf,filter=myAssetFilter)
平滑流Smooth Streaming https://amsv3account-cne21.streaming.media.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/bigbuckbunny.ism/manifest(filter=myAssetFilter)

再现内容筛选Rendition filtering

可选择将资产编码成多个编码配置文件(H.264 Baseline、H.264 High、AACL、AACH、Dolby Digital Plus),以及多个优质比特率。You can choose to encode your asset to multiple encoding profiles (H.264 Baseline, H.264 High, AACL, AACH, Dolby Digital Plus) and multiple quality bitrates. 不过,并非所有的客户端设备都支持所有的资产配置文件和比特率。However, not all client devices will support all your asset's profiles and bitrates. 例如,早期的 Android 设备只支持 H.264 Baseline+AACL。For example, older Android devices support only H.264 Baseline+AACL. 将较高的比特率发送到不能利用这些优势的设备会浪费带宽及设备计算资源。Sending higher bitrates to a device that can't get the benefits wastes bandwidth and device computation. 此类设备必须解码所有给定信息,目的仅仅是为了缩小信息以便能够显示。Such a device must decode all the given information, only to scale it down for display.

借助动态清单,可以创建设备配置文件(例如移动配置文件、控制台或 HD/SD),并包含你想要纳入配置文件中的曲目与质量。With Dynamic Manifest, you can create device profiles (such as mobile, console, or HD/SD) and include the tracks and qualities that you want to be a part of each profile. 这称为“再现内容筛选”。That's called rendition filtering. 下图显示了一个示例。The following diagram shows an example of it.

使用动态清单的再现内容筛选示例

以下示例使用编码器将夹层资产编码成七个 ISO MP4 视频再现内容(从 180p 到 1080p)。In the following example, an encoder was used to encode a mezzanine asset into seven ISO MP4s video renditions (from 180p to 1080p). 编码的资产可动态打包成以下任一流协议:HLS、MPEG DASH 和平滑流式处理。The encoded asset can be dynamically packaged into any of the following streaming protocols: HLS, MPEG DASH, and Smooth.

下图的顶部显示了不包含筛选器的资产的 HLS 清单。The top of the following diagram shows the HLS manifest for the asset with no filters. (它包含全部七个再现内容。)左下角显示了名为“ott”的筛选器已应用到 HLS 清单。(It contains all seven renditions.) In the lower left, the diagram shows an HLS manifest to which a filter named "ott" was applied. “ott”筛选器指定要删除所有低于 1 Mbps 的比特率,因此最差的两个质量级别已从响应中剥除。The "ott" filter specifies the removal of all bitrates below 1 Mbps, so the bottom two quality levels were stripped off in the response. 右下角显示了名为“mobile”的筛选器已应用到 HLS 清单。In the lower right, the diagram shows the HLS manifest to which a filter named "mobile" was applied. “mobile”筛选器指定要删除分辨率大于 720p 的再现内容,因此已剥除两个 1080p 再现内容。The "mobile" filter specifies the removal of renditions where the resolution is larger than 720p, so the two 1080p renditions were stripped off.

使用动态清单的再现内容筛选

删除语言音轨Removing language tracks

你的资产可能包含多种音频语言,例如英语、西班牙语、法语等。Your assets might include multiple audio languages such as English, Spanish, French, and so on. 通常,播放器 SDK 管理器会按默认选择音频轨迹,并根据用户的选择来选择可用音频轨迹。Usually, the Player SDK manages default audio track selection and available audio tracks per user selection.

开发此类播放器 SDK 相当有挑战性,因为各个设备特定的播放器框架之间需要不同的实现。Developing such Player SDKs is challenging because it requires different implementations across device-specific player frameworks. 此外,播放器 API 在某些平台上受到限制,且不包含音频选择功能,因此用户无法选择或更改默认的音频轨迹。使用资产筛选器,可以通过创建只包含所需音频语言的筛选器来控制行为。Also, on some platforms, Player APIs are limited and don't include the audio selection feature where users can't select or change the default audio track. With asset filters, you can control the behavior by creating filters that only include desired audio languages.

使用动态清单的语言轨迹筛选

修剪资产开头Trimming the start of an asset

大多数实时流事件中,操作员必须在发生实际事件之前进行某些测试。In most live streaming events, operators run some tests before the actual event. 例如,他们可以在事件开始之前提供如下盖板:“节目即将开始。”For example, they might include a slate like this before the start of the event: "Program will begin momentarily."

如果节目正在存档,测试和静态数据也会一并存档并包含在演播中。If the program is archiving, the test and slate data are also archived and included in the presentation. 但是,此信息不应向客户端显示。However, this information shouldn't be shown to the clients. 借助动态清单,可以创建开始时间筛选器,并从清单中删除不需要的数据。With Dynamic Manifest, you can create a start time filter and remove the unwanted data from the manifest.

使用动态清单修剪资产的开头

基于实时存档创建子剪辑(视图)Creating subclips (views) from a live archive

许多直播活动长期运行,直播存档可能包含多个活动。Many live events are long running and live archive might include multiple events. 直播活动结束后,广播者可能需要将实时存档分解成符合逻辑的节目启动和停止序列。After the live event ends, broadcasters may want to break up the live archive into logical program start and stop sequences.

可以单独发布这些虚拟节目,但不后续处理实时存档,也不创建独立的资产。You can publish these virtual programs separately without post processing the live archive and not creating separate assets. 此类虚拟节目的示例包括橄榄球或篮球比赛中的节、棒球比赛中的局,或者任何体育节目中的单项赛事。Examples of such virtual programs are the quarters of a football or basketball game, innings in baseball, or individual events of any sports program.

借助动态清单,可以使用开始/结束时间创建筛选器,并基于实时存档创建虚拟视图。With Dynamic Manifest, you can create filters by using start/end times and create virtual views over the top of your live archive.

使用动态清单的子剪辑筛选器

下面是筛选的资产:Here's the filtered asset:

使用动态清单筛选的资产

调整演播窗口 (DVR)Adjusting the presentation window (DVR)

目前,Azure 媒体服务提供持续时间可设为 1 分钟到 25 小时的循环存档。Currently, Azure Media Services offers circular archive where the duration can be configured between 1 minute - 25 hours. 清单筛选可以基于存档创建循环 DVR 窗口存档,而不会删除媒体。Manifest filtering can be used to create a rolling DVR window over the top of the archive, without deleting media. 许多情况下,广播者需要提供受限制的 DVR 窗口,此窗口可随着实时边缘移动,并同时保留更大的存档窗口。There are many scenarios where broadcasters want to provide a limited DVR window to move with the live edge and at the same time keep a bigger archiving window. 广播者可能想要使用超出 DVR 窗口的数据来突出显示剪辑,或者想要为不同的设备提供不同的 DVR 窗口。A broadcaster may want to use the data that's out of the DVR window to highlight clips, or they may want to provide different DVR windows for different devices. 例如,大多数移动设备不处理大的 DVR 窗口(可以让移动设备有 2 分钟的 DVR 窗口,桌面客户端有 1 小时的 DVR 窗口)。For example, most of the mobile devices don't handle large DVR windows (you can have a 2-minute DVR window for mobile devices and one hour for desktop clients).

包含动态清单的 DVR 窗口

调整实时补偿(实时位置)Adjusting LiveBackoff (live position)

清单筛选可用于删除实时节目的实时边缘几秒钟的时间。Manifest filtering can be used to remove several seconds from the live edge of a live program. 通过筛选,广播者便可以在观众收到流之前(倒退 30 秒)先观赏预览发布点的演播,并创建广告插入点。Filtering allows broadcasters to watch the presentation on the preview publication point and create advertisement insertion points before the viewers receive the stream (backed off by 30 seconds). 接下来,广播者可将这些广告及时推送到他们的客户端框架,以便能够接收与处理信息,并借机播放广告。Broadcasters can then push these advertisements to their client frameworks in time for them to receive and process the information before the advertisement opportunity.

除了广告支持外,还可使用实时补偿设置来调整观看者位置,以便在客户端偏移并命中实时边缘时,仍然可以从服务器获取片段。In addition to the advertisement support, the live back-off setting can be used to adjust the viewers' position so that when clients drift and hit the live edge, they can still get fragments from the server. 这样,客户端就不会收到 HTTP 404 或 412 错误。That way, clients won't get an HTTP 404 or 412 error.

使用动态清单按实时后退时间筛选

将多个规则合并成单个筛选器Combining multiple rules in a single filter

可以将多个筛选规则合并成单个筛选器。You can combine multiple filtering rules in a single filter. 例如,可以定义一个“范围规则”,将静态内容从实时存档中删除,并筛选出可用的比特率。For example, you can define a "range rule" to remove slates from a live archive and also filter out available bitrates. 应用多项筛选规则时,最终结果是所有规则的交集。When you're applying multiple filtering rules, the end result is the intersection of all rules.

使用动态清单的多个筛选规则

组合多个筛选器(筛选器组合)Combining multiple filters (filter composition)

也可以在单个 URL 中组合多个筛选器。You can also combine multiple filters in a single URL. 以下方案演示了可能需要组合多个筛选器的原因:The following scenario demonstrates why you might want to combine filters:

  1. 需要筛选视频质量(目的是限制视频质量)以供 Android 或 iPad 之类的移动设备使用。You need to filter your video qualities for mobile devices, like Android or iPad (in order to limit video qualities). 若要删除其质量不符合需要的视频,可创建一个适合设备配置文件的帐户筛选器。To remove the unwanted qualities, you'll create an account filter suitable for the device profiles. 帐户筛选器可用于同一媒体服务帐户下的所有资产,这些资产并没有更多的其他联系。You can use account filters for all your assets under the same Media Services account without any further association.
  2. 还可以修改资产的开始时间和结束时间。You also want to trim the start and end time of an asset. 若要执行修剪,需要创建一个资产筛选器并设置开始/结束时间。To do the trimming, you'll create an asset filter and set the start/end time.
  3. 需要组合这两个筛选器。You want to combine both of these filters. 如果不组合,则需要将质量筛选添加到修剪筛选器,这会导致筛选器的使用更加困难。Without combination, you would need to add quality filtering to the trimming filter, which would make filter usage more difficult.

若要组合筛选器,请在清单/播放列表 URL 中设置分号分隔格式的筛选器名称。To combine filters, set the filter names to the manifest/playlist URL in semicolon-delimited format. 假设你有一个名为 MyMobileDevice 的筛选器,用于筛选质量,另外还有一个名为 MyStartTime 的筛选器,用于设置具体的开始时间。Let’s assume you have a filter named MyMobileDevice that filters qualities, and you have another named MyStartTime to set a specific start time. 最多可以组合三个筛选器。You can combine up to three filters.

有关详细信息,请参阅 此博客文章For more information, see this blog post.

注意事项和限制Considerations and limitations

  • 不应设置 VOD 筛选器的 forceEndTimestamppresentationWindowDurationliveBackoffDuration 值。The values for forceEndTimestamp, presentationWindowDuration, and liveBackoffDuration shouldn't be set for a VOD filter. 它们仅用于动态筛选方案。They're used only for live filter scenarios.

  • 动态清单在 GOP 边界(关键帧)内运行,因此修剪后具有精确的 GOP。A dynamic manifest operates in GOP boundaries (key frames), so trimming has GOP accuracy.

  • 可对帐户和资产筛选器使用相同的筛选器名称。You can use the same filter name for account and asset filters. 资产筛选器的优先级更高,会替代帐户筛选器。Asset filters have higher precedence and will override account filters.

  • 如果更新筛选器,则流式处理终结点需要最多 2 分钟来刷新规则。If you update a filter, it can take up to 2 minutes for the streaming endpoint to refresh the rules. 如果使用筛选器提供内容(并在代理缓存中缓存内容),则更新这些筛选器会导致播放器失败。If you used filters to serve the content (and you cached the content in proxies caches), updating these filters can result in player failures. 我们建议在更新筛选器之后清除缓存。We recommend that you clear the cache after updating the filter. 如果无法做到这一点,请考虑使用其他筛选器。If this option isn't possible, consider using a different filter.

  • 客户需要手动下载清单,并分析确切的开始时间戳和时间刻度。Customers need to manually download the manifest and parse the exact start time stamp and time scale.

    • 若要确定资产中轨迹的属性,请获取并检查清单文件To determine properties of the tracks in an asset, get and examine the manifest file.
    • 设置资产筛选器时间戳属性的公式是:The formula to set the asset filter time-stamp properties is:
      startTimestamp = <清单中的开始时间> + <预期筛选器开始时间(秒)>* 时间刻度startTimestamp = <start time in the manifest> + <expected filter start time in seconds> * timescale

后续步骤Next steps

以下文章介绍了如何以编程方式创建筛选器:The following articles show how to create filters programmatically: