向客户传送内容Deliver content to customers

向客户传送流或视频点播内容时,目标在于向处于不同网络条件下的各种设备传送优质视频。When you're delivering your streaming or video-on-demand content to customers, your goal is to deliver high-quality video to various devices under different network conditions.

若要实现此目标,可以:To achieve this goal, you can:

  • 将流编码为多比特率(自适应比特率)视频流。Encode your stream to a multi-bitrate (adaptive bitrate) video stream. 此操作可负责处理质量和网络条件问题。This will take care of quality and network conditions.
  • 使用 Azure 媒体服务动态打包功能将流重新动态打包为不同的协议。Use Azure Media Services dynamic packaging to dynamically re-package your stream into different protocols. 此操作可负责处理不同设备上的流式处理问题。This will take care of streaming on different devices. 媒体服务支持以下自适应比特率流式处理技术的传送:Media Services supports delivery of the following adaptive bitrate streaming technologies:
    • HTTP Live Streaming (HLS) - 向 URL 的“/Manifest”部分添加“(format=m3u8-aapl)”路径,告知流式处理源服务器返回供 Apple iOS 本机设备使用的 HLS 内容(有关详细信息,请参阅定位符URL);HTTP Live Streaming (HLS) - add "(format=m3u8-aapl)" path to the "/Manifest" portion of the URL to tell the streaming origin server to return back HLS content for consumption on Apple iOS native devices (for details, see locators and URLs),
    • MPEG DASH - 向 URL 的“/Manifest”部分添加“(format=mpd-time-csf)”路径,告知流式处理源服务器返回 MPEG-DASH(有关详细信息,请参阅定位符URL);MPEG-DASH - add "(format=mpd-time-csf)" path to the "/Manifest" portion of the URL to tell the streaming origin server to return back MPEG-DASH (for details, see locators and URLs),
    • 平滑流式处理 。Smooth Streaming.

Note

创建 AMS 帐户后,会将一个处于“已停止”状态的默认流式处理终结点添加到帐户。 When your AMS account is created a default streaming endpoint is added to your account in the Stopped state. 若要开始流式传输内容并利用动态打包和动态加密,要从中流式传输内容的流式处理终结点必须处于“正在运行”状态。 To start streaming your content and take advantage of dynamic packaging and dynamic encryption, the streaming endpoint from which you want to stream content has to be in the Running state.

本文概述重要的内容传送概念。This article gives an overview of important content delivery concepts.

若要查看已知问题,请参阅已知问题To check known issues, see Known issues.

动态打包Dynamic packaging

借助媒体服务提供的动态打包功能,可采用媒体服务支持的流式传输格式(MPEG-DASH、HLS、平滑流式处理)传送自适应比特率 MP4 或平滑流式处理编码内容,而不必重新打包成这些流式传输格式。With the dynamic packaging that Media Services provides, you can deliver your adaptive bitrate MP4 or Smooth Streaming encoded content in streaming formats supported by Media Services (MPEG-DASH, HLS, Smooth Streaming,) without having to re-package into these streaming formats. 我们建议使用动态打包功能传送内容。We recommend delivering your content with dynamic packaging.

若要利用动态打包,需将夹层(源)文件编码为一组自适应比特率 MP4 文件或自适应比特率平滑流式处理文件。To take advantage of dynamic packaging, you need to encode your mezzanine (source) file into a set of adaptive-bitrate MP4 files or adaptive bitrate Smooth Streaming files.

借助动态打包功能,可存储和播放使用单一存储格式的文件。With dynamic packaging, you store and pay for the files in single storage format. 媒体服务会根据请求生成并提供适当的响应。Media Services will build and serve the appropriate response based on your requests.

动态打包适用于标准和高级流式处理终结点。Dynamic packaging is available for standard and premium streaming endpoints.

有关详细信息,请参阅动态打包For more information, see Dynamic packaging.

筛选器和动态清单Filters and dynamic manifests

借助媒体服务,可为资产定义筛选器。You can define filters for your assets with Media Services. 这些筛选器是服务器端规则,可帮助客户完成类似如下的操作:播放视频的特定部分,或指定客户设备可以处理的一个子集的音频和视频呈现形式(而非与该资产相关的所有呈现形式)。These filters are server-side rules that help your customers do things like play a specific section of a video or specify a subset of audio and video renditions that your customer's device can handle (instead of all the renditions that are associated with the asset). 通过客户请求根据一个或多个指定的筛选器流式传输视频时创建的 动态清单 ,可实现此筛选操作。This filtering is achieved through dynamic manifests that are created when your customer requests to stream a video based on one or more specified filters.

有关详细信息,请参阅筛选器和动态清单For more information, see Filters and dynamic manifests.

定位符Locators

若要为用户提供一个可用于流式传输内容或下载内容的 URL,首先需要通过创建定位符来发布资产。To provide your user with a URL that can be used to stream or download your content, you first need to publish your asset by creating a locator. 定位符提供访问资产中所含文件的入口点。A locator provides an entry point to access the files contained in an asset. 媒体服务支持两种类型的定位符:Media Services supports two types of locators:

  • OnDemandOrigin 定位符。OnDemandOrigin locators. 这些定位符用于流媒体(例如,MPEG-DASH、HLS 或平滑流式处理)或渐进式下载文件。These are used to stream media (for example, MPEG-DASH, HLS, or Smooth Streaming) or progressively download files.
  • 共享访问签名 (SAS) URL 定位符。Shared access signature (SAS) URL locators. 这些定位符用于将媒体文件下载到本地计算机。These are used to download media files to your local computer.

访问策略 用于定义客户端可以访问特定资产的权限(例如读取、写入和列出)和持续时间。An access policy is used to define the permissions (such as read, write, and list) and duration for which a client has access for a particular asset. 请注意,创建 OnDemandOrigin 定位符时,不应使用列出权限 (AccessPermissions.List)。Note that the list permission (AccessPermissions.List) should not be used in creating an OnDemandOrigin locator.

定位符具有过期日期。Locators have expiration dates. Azure 门户将定位符的过期日期设置为 100 年以后。The Azure portal sets an expiration date 100 years in the future for locators.

Note

如果在 2015 年 3 月之前使用 Azure 门户创建定位符,这些定位符设置为两年后过期。If you used the Azure portal to create locators before March 2015, those locators were set to expire after two years.

若要更新定位符的过期日期,请使用 REST.NET API。To update an expiration date on a locator, use REST or .NET APIs. 请注意,更新 SAS 定位符的过期日期时,URL 会发生变化。Note that when you update the expiration date of a SAS locator, the URL changes.

定位符不用于管理按用户的访问控制。Locators are not designed to manage per-user access control. 通过数字版权管理 (DRM) 解决方案,可以为不同的用户提供不同的访问权限。You can give different access rights to individual users by using Digital Rights Management (DRM) solutions. 有关详细信息,请参阅 保护媒体For more information, see Securing Media.

创建定位符时,可能会由于 Azure 存储中所需存储和传播进程的影响,出现 30 秒的延迟。When you create a locator, there may be a 30-second delay due to required storage and propagation processes in Azure Storage.

自适应流Adaptive streaming

自适应比特率技术允许视频播放器应用程序确定网络条件并从多个比特率中选择。Adaptive bitrate technologies allow video player applications to determine network conditions and select from several bitrates. 网络通信质量下降时,客户端可以选择较低的比特率,以便能够以较低的视频质量继续播放视频。When network communication degrades, the client can select a lower bitrate so playback can continue with lower video quality. 网络条件改善时,客户端可以切换到较高的比特率,提高视频质量。As network conditions improve, the client can switch to a higher bitrate with improved video quality. Azure 媒体服务支持以下自适应比特率技术:HTTP Live Streaming (HLS)、平滑流式处理 和 MPEG-DASH。Azure Media Services supports the following adaptive bitrate technologies: HTTP Live Streaming (HLS), Smooth Streaming, and MPEG-DASH.

若要为用户提供流式处理 URL,必须先创建一个 OnDemandOrigin 定位符。To provide users with streaming URLs, you first must create an OnDemandOrigin locator. 通过创建定位符,可获得包含要流式传输的内容的资产的基本路径。Creating the locator gives you the base path to the asset that contains the content you want to stream. 但是,为了能够流式传输此内容,需要进一步修改此路径。However, to be able to stream this content, you need to modify this path further. 若要构造流式处理清单文件的完整 URL,必须将定位符的路径值与清单 (filename.ism) 文件名连接起来。To construct a full URL to the streaming manifest file, you must concatenate the locator’s path value and the manifest (filename.ism) file name. 然后,向定位符路径追加/Manifest 和相应的格式(如果需要)。Then append /Manifest and an appropriate format (if needed) to the locator path.

Note

也可通过 TLS 连接流式传输内容。You can also stream your content over a TLS connection. 为此,请确保流 URL 以 HTTPS 开头。To do this, make sure your streaming URLs start with HTTPS. 请注意,AMS 目前不支持对自定义域使用 TLS。Note that, currently, AMS doesn’t support TLS with custom domains.

如果要从中传送内容的流式处理终结点是在 2014 年 9 月 10 日之后创建的,则只能通过 TLS 流式传输内容。You can only stream over TLS if the streaming endpoint from which you deliver your content was created after September 10th, 2014. 如果流式处理 URL 基于 2014 年 9 月 10 日之后创建的流式处理终结点,则 URL 会包含“streaming.mediaservices.chinacloudapi.cn”。If your streaming URLs are based on the streaming endpoints created after September 10th, 2014, the URL contains “streaming.mediaservices.chinacloudapi.cn.” 包含“origin.mediaservices.chinacloudapi.cn”(旧格式)的流式处理 URL 不支持 TLS。Streaming URLs that contain “origin.mediaservices.chinacloudapi.cn” (the old format) do not support TLS. 如果 URL 采用旧格式,并且你希望能够通过 TLS 流式传输内容,请创建新的流式处理终结点。If your URL is in the old format and you want to be able to stream over TLS, create a new streaming endpoint. 使用基于新流式处理终结点的 URL 通过 TLS 流式传输内容。Use URLs based on the new streaming endpoint to stream your content over TLS.

流式处理 URL 格式Streaming URL formats

MPEG-DASH 格式MPEG-DASH format

{流式处理终结点名称-媒体服务帐户名称}.streaming.mediaservices.chinacloudapi.cn/{定位符 ID}/{文件名}.ism/Manifest(format=mpd-time-csf){streaming endpoint name-media services account name}.streaming.mediaservices.chinacloudapi.cn/{locator ID}/{filename}.ism/Manifest(format=mpd-time-csf)

http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=mpd-time-csf)http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=mpd-time-csf)

Apple HTTP Live Streaming (HLS) V4 格式Apple HTTP Live Streaming (HLS) V4 format

{流式处理终结点名称-媒体服务帐户名称}.streaming.mediaservices.chinacloudapi.cn/{定位符 ID}/{文件名}.ism/Manifest(format=m3u8-aapl){streaming endpoint name-media services account name}.streaming.mediaservices.chinacloudapi.cn/{locator ID}/{filename}.ism/Manifest(format=m3u8-aapl)

http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=m3u8-aapl)http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=m3u8-aapl)

Apple HTTP Live Streaming (HLS) V3 格式Apple HTTP Live Streaming (HLS) V3 format

{流式处理终结点名称-媒体服务帐户名称}.streaming.mediaservices.chinacloudapi.cn/{定位符 ID}/{文件名}.ism/Manifest(format=m3u8-aapl-v3){streaming endpoint name-media services account name}.streaming.mediaservices.chinacloudapi.cn/{locator ID}/{filename}.ism/Manifest(format=m3u8-aapl-v3)

http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=m3u8-aapl-v3)http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=m3u8-aapl-v3)

Apple HTTP Live Streaming (HLS) 格式带有仅音频筛选器Apple HTTP Live Streaming (HLS) format with audio-only filter

默认情况下,仅音频轨道已包括在 HLS 清单中。By default, audio-only tracks are included in the HLS manifest. 这是针对手机网络进行 Apple 应用商店认证所必需的。This is required for Apple Store certification for cellular networks. 在这种情况下,如果客户端没有足够的带宽或者通过 2G 连接进行连接,则播放轨道会切换成仅音频。In this case, if a client doesn’t have sufficient bandwidth or is connected over a 2G connection, playback switches to audio-only. 这有助于让内容保持流式传输而无需缓冲,但没有视频内容。This helps to keep content streaming without buffering, but there is no video. 在某些情况下,相对于仅播放音频而言,用户更愿意选择缓冲播放视频。In some scenarios, player buffering might be preferred over audio-only. 如果希望删除仅音频轨道,可在 URL 中添加 audio-only=falseIf you want to remove the audio-only track, add audio-only=false to the URL.

http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=m3u8-aapl-v3,audio-only=false)http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=m3u8-aapl-v3,audio-only=false)

有关详细信息,请参阅 Dynamic Manifest Composition support and HLS output additional features(动态清单组合支持和其他 HSL 输出功能)。For more information, see Dynamic Manifest Composition support and HLS output additional features.

平滑流格式Smooth Streaming format

{流式处理终结点名称-媒体服务帐户名称}.streaming.mediaservices.chinacloudapi.cn/{定位符 ID}/{文件名}.ism/Manifest{streaming endpoint name-media services account name}.streaming.mediaservices.chinacloudapi.cn/{locator ID}/{filename}.ism/Manifest

示例:Example:

http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest

平滑流式处理 2.0 清单(旧清单)Smooth Streaming 2.0 manifest (legacy manifest)

默认情况下,平滑流式处理清单格式包含重复标记(r 标记)。By default, Smooth Streaming manifest format contains the repeat tag (r-tag). 但是,一些播放器不支持 r 标记。However, some players do not support the r-tag. 使用这些播放器的客户端可以使用禁用 r 标记的格式:Clients with these players can use a format that disables the r-tag:

{streaming endpoint name-media services account name}.streaming.mediaservices.chinacloudapi.cn/{locator ID}/{filename}.ism/Manifest(format=fmp4-v20){streaming endpoint name-media services account name}.streaming.mediaservices.chinacloudapi.cn/{locator ID}/{filename}.ism/Manifest(format=fmp4-v20)

http://testendpoint-testaccount.streaming.mediaservices.chinacloudapi.cn/fecebb23-46f6-490d-8b70-203e86b0df58/BigBuckBunny.ism/Manifest(format=fmp4-v20)

渐进式下载Progressive download

通过渐进式下载,可在下载完整个文件之前开始播放媒体。With progressive download, you can start playing media before the entire file has been downloaded. 无法渐进式下载 .ism* (ismv、isma、ismt 或 ismc) 文件。You cannot progressively download .ism* (ismv, isma, ismt, or ismc) files.

若要渐进式下载内容,请使用 OnDemandOrigin 类型的定位符。To progressively download content, use the OnDemandOrigin type of locator. 以下示例演示了基于 OnDemandOrigin 类型的定位符的 URL:The following example shows the URL that is based on the OnDemandOrigin type of locator:

http://amstest1.streaming.mediaservices.chinacloudapi.cn/3c5fe676-199c-4620-9b03-ba014900f214/BigBuckBunny_H264_650kbps_AAC_und_ch2_96kbps.mp4

必须解密希望从源服务进行流式传输的所有存储加密资产,才能进行渐进式下载。You must decrypt any storage-encrypted assets that you want to stream from the origin service for progressive download.

下载Download

要将内容下载到客户端设备,必须创建 SAS 定位符。To download your content to a client device, you must create a SAS Locator. 使用 SAS 定位符可以访问文件所在的 Azure 存储容器。The SAS locator gives you access to the Azure Storage container where your file is located. 要构建下载 URL,必须将文件名嵌入到主机和 SAS 签名之间。To build the download URL, you have to embed the file name between the host and SAS signature.

以下示例演示了基于 SAS 定位符的 URL:The following example shows the URL that is based on the SAS locator:

https://test001.blob.core.chinacloudapi.cn/asset-ca7a4c3f-9eb5-4fd8-a898-459cb17761bd/BigBuckBunny.mp4?sv=2012-02-12&se=2014-05-03T01%3A23%3A50Z&sr=c&si=7c093e7c-7dab-45b4-beb4-2bfdff764bb5&sig=msEHP90c6JHXEOtTyIWqD7xio91GtVg0UIzjdpFscHk%3D

请注意以下事项:The following considerations apply:

  • 必须解密希望从源服务进行流式传输的所有存储加密资产,才能进行渐进式下载。You must decrypt any storage-encrypted assets that you want to stream from the origin service for progressive download.
  • 未在 12 小时内完成的下载会失败。A download that has not finished within 12 hours will fail.

流式处理终结点Streaming endpoints

流式处理终结点代表一个流式处理服务,它可以直接将内容分发给客户端播放器应用程序。A streaming endpoint represents a streaming service that can deliver content directly to a client player application. 流式处理终结点服务的出站流可以是实时流,也可以是媒体服务帐户中的视频点播资产。The outbound stream from a streaming endpoint service can be a live stream or a video-on-demand asset in your Media Services account. 有两种类型的流式处理终结点,标准高级There are two types of streaming endpoints, standard and premium. 有关详细信息,请参阅: 流式处理终结点概述For more information, see Streaming endpoints overview.

Note

创建 AMS 帐户后,会将一个处于“已停止”状态的默认流式处理终结点添加到帐户。 When your AMS account is created a default streaming endpoint is added to your account in the Stopped state. 若要开始对内容进行流式处理并利用动态打包和动态加密功能,必须确保要从其流式获取内容的流式处理终结点处于“正在运行”状态。To start streaming your content and take advantage of dynamic packaging and dynamic encryption, the streaming endpoint from which you want to stream content has to be in the Running state.

已知问题Known issues

更改为平滑流式处理清单版本Changes to Smooth Streaming manifest version

在 2016 年 7 月的服务版本之前,使用 Media Encoder Standard、媒体编码器高级工作流或早期的 Azure 媒体编码器生成的资产通过动态打包功能进行流式处理,此时返回的平滑流式处理清单遵从 2.0 版的要求。Before the July 2016 service release--when assets produced by Media Encoder Standard, Media Encoder Premium Workflow, or the earlier Azure Media Encoder were streamed by using dynamic packaging--the Smooth Streaming manifest returned would conform to version 2.0. 在 2.0 版本中,片段持续时间不使用所谓的重复 ('r') 标记。In version 2.0, the fragment durations do not use the so-called repeat (‘r’) tags. 例如:For example:

<?xml version="1.0" encoding="UTF-8"?>
<SmoothStreamingMedia MajorVersion="2" MinorVersion="0" Duration="8000" TimeScale="1000">
    <StreamIndex Chunks="4" Type="video" Url="QualityLevels({bitrate})/Fragments(video={start time})" QualityLevels="3" Subtype="" Name="video" TimeScale="1000">
        <QualityLevel Index="0" Bitrate="1000000" FourCC="AVC1" MaxWidth="640" MaxHeight="360" CodecPrivateData="00000001674D4029965201405FF2E02A100000030010000003032E0A000F42400040167F18E3050007A12000200B3F8C70ED0B16890000000168EB7352" />
        <c t="0" d="2000" n="0" />
        <c d="2000" />
        <c d="2000" />
        <c d="2000" />
    </StreamIndex>
</SmoothStreamingMedia>

在 2016 年 7 月的服务版本中,生成的平滑流式处理清单遵从 2.2 版的要求,其片段持续时间使用重复标记。In the July 2016 service release, the generated Smooth Streaming manifest conforms to version 2.2, with fragment durations using repeat tags. 例如:For example:

<?xml version="1.0" encoding="UTF-8"?>
<SmoothStreamingMedia MajorVersion="2" MinorVersion="2" Duration="8000" TimeScale="1000">
    <StreamIndex Chunks="4" Type="video" Url="QualityLevels({bitrate})/Fragments(video={start time})" QualityLevels="3" Subtype="" Name="video" TimeScale="1000">
        <QualityLevel Index="0" Bitrate="1000000" FourCC="AVC1" MaxWidth="640" MaxHeight="360" CodecPrivateData="00000001674D4029965201405FF2E02A100000030010000003032E0A000F42400040167F18E3050007A12000200B3F8C70ED0B16890000000168EB7352" />
        <c t="0" d="2000" r="4" />
    </StreamIndex>
</SmoothStreamingMedia>

一些旧平滑流式处理客户端可能不支持此重复标记,并且无法加载清单。Some of the legacy Smooth Streaming clients may not support the repeat tags and will fail to load the manifest. 若要解决此问题,可以使用旧清单格式参数 (format=fmp4-v20) ,或将客户端更新到支持重复标记的最新版本。To mitigate this issue, you can use the legacy manifest format parameter (format=fmp4-v20) or update your client to the latest version, which supports repeat tags. 有关详细信息,请参阅平滑流式处理 2.0For more information, see Smooth Streaming 2.0.

媒体服务学习路径Media Services learning paths

媒体服务 v3(最新版本)Media Services v3 (latest)

查看最新版本的 Azure 媒体服务!Check out the latest version of Azure Media Services!

媒体服务 v2(旧版)Media Services v2 (legacy)

轮转存储密钥后更新媒体服务定位符Update Media Services locators after rolling storage keys