适用于 Windows 10 的 PlayReady 脱机流式处理Offline PlayReady Streaming for Windows 10

媒体服务徽标media services logo


Google Widevine 内容保护服务目前在 Azure 中国区域不可用。Google Widevine content protection services are currently unavailable in the Azure China regions.


不会向媒体服务 v2 添加任何新特性或新功能。No new features or functionality are being added to Media Services v2.
查看最新版本:媒体服务 v3Check out the latest version, Media Services v3. 另请参阅从 v2 到 v3 的迁移指南Also, see migration guidance from v2 to v3

Azure 媒体服务支持带 DRM 保护的脱机下载/播放。Azure Media Services support offline download/playback with DRM protection. 本文涵盖用于 Windows 10/PlayReady 客户端的对 Azure 媒体服务的脱机支持。This article covers offline support of Azure Media Services for Windows 10/PlayReady clients. 可以通过以下文章了解对 iOS/FairPlay 设备的脱机模式支持:You can read about the offline mode support for iOS/FairPlay devices in the following articles:

适用于 iOS 的 FairPlay 脱机流式处理Offline FairPlay Streaming for iOS


本节介绍有关脱机模式播放的一些背景,特别是以下问题的原因:This section gives some background on offline mode playback, especially why:

  • 在某些国家/地区,Internet 可用性和/或宽带仍然受到限制。In some countries/regions, Internet availability and/or bandwidth is still limited.  为获得满意的观看体验,用户可能选择首先下载以便能够观看高分辨率的内容。Users may choose to download first to be able to watch content in high enough resolution for satisfactory viewing experience. 在此情况下,通常问题不在于网络可用性,而在于受限的网络宽带。In this case, more often, the issue is not network availability, rather it is limited network bandwidth. 此时,OTT/OVP 提供程序就会请求提供脱机模式支持。OTT/OVP providers are asking for offline mode support.
  • 在 Netflix 2016 年第 3 季度股东大会上,Netflix 首席执行官 Reed Hastings 表示,下载内容是“经常请求的功能”,“我们对此持开放态度”。As disclosed at Netflix 2016 Q3 shareholder conference, downloading content is a “oft-requested feature”, and “we are open to it” said by Reed Hastings, Netflix CEO.
  • 某些内容提供程序可能不允许在某个国家/地区的边界之外进行 DRM 许可证传送。Some content providers may disallow DRM license delivery beyond a country/region's border. 如果用户想在国外旅行期间查看内容,需要脱机下载。If a user needs to travel abroad and still wants to watch content, offline download is needed.

实现脱机模式所面临的挑战如下:The challenge we face in implementing offline mode is the following:

  • 许多播放器、编码器工具都支持 MP4,但 MP4 容器和 DRM 之间不存在绑定;MP4 is supported by many players, encoder tools, but there is no binding between MP4 container and DRM;
  • 从长远来看,具有 CENC 的 CFF 是趋势。In the long term, CFF with CENC is the way to go. 然而,目前工具/播放机支持生态系统尚未出现。However, today, the tools/player support ecosystem is not there yet. 现在需要一个解决方案。We need a solution, today.

其理念为:具有 H264/AAC 的平滑流式处理 (PIFF) 文件格式与 PlayReady (AES-128 CTR) 存在绑定。The idea is: smooth streaming (PIFF) file format with H264/AAC has a binding with PlayReady (AES-128 CTR). 平滑流式处理 .ismv 文件(假设音频混合在视频中)本身就是 fMP4,可以用于播放。Individual smooth streaming .ismv file (assuming audio is muxed in video) is itself a fMP4 and can be used for playback. 如果平滑流式处理内容经过 PlayReady 加密,则每个 .ismv 文件会变成受 PlayReady 保护的片段 MP4。If a smooth streaming content goes through PlayReady encryption, each .ismv file becomes a PlayReady protected fragmented MP4. 我们可以选择具有首选比特率的 .ismv 文件,并将其重命名为 .mp4 以便下载。We can choose an .ismv file with the preferred bitrate and rename it as .mp4 for download.

有以下两种方式用于承载 PlayReady 保护的 MP4,以便进行渐进式下载:There are two options for hosting the PlayReady protected MP4 for progressive download:

  • 可以将此 MP4 放入同一容器/媒体服务资产中,并利用 Azure 媒体服务流式处理终结点进行渐进式下载;One can put this MP4 in the same container/media service asset and leverage Azure Media Services streaming endpoint for progressive download;
  • 使用 SAS 定位符直接从 Azure 存储进行渐进式下载,绕过 Azure 媒体服务。One can use SAS locator for progressive download directly from Azure Storage, bypassing Azure Media Services.

可以使用两种类型的 PlayReady 许可证交付:You can use two types of PlayReady license delivery:

  • Azure 媒体服务中的 PlayReady 许可证交付服务;PlayReady license delivery service in Azure Media Services;
  • PlayReady 许可证服务器可以托管在任何位置。PlayReady license servers hosted anywhere.

对于播放测试,我们在 Windows 10 上使用了通用 Windows 应用程序。For playback testing, I used a Universal Windows Application on Windows 10. Windows 10 通用示例中,有一个名为 Adaptive Streaming Sample(自适应流式处理示例)的基础播放器示例。In Windows 10 Universal samples, there is a basic player sample called Adaptive Streaming Sample. 我们只需要添加代码,选择下载的视频并将其用作源,而不是用作自适应流式处理源。All we have to do is to add the code for us to pick downloaded video and use it as the source, instead of adaptive streaming source. 按钮单击事件处理程序中的更改:The changes are in button click event handler:

private async void LoadUri_Click(object sender, RoutedEventArgs e)
    //Uri uri;
    //if (!Uri.TryCreate(UriBox.Text, UriKind.Absolute, out uri))
    // Log("Malformed Uri in Load text box.");
    // return;
    //LoadSourceFromUriTask = LoadSourceFromUriAsync(uri);
    //await LoadSourceFromUriTask;

    //willzhan change start
    // Create and open the file picker
    FileOpenPicker openPicker = new FileOpenPicker();
    openPicker.ViewMode = PickerViewMode.Thumbnail;
    openPicker.SuggestedStartLocation = PickerLocationId.ComputerFolder;

    StorageFile file = await openPicker.PickSingleFileAsync();

    if (file != null)
       //rootPage.NotifyUser("Picked video: " + file.Name, NotifyType.StatusMessage);
       this.mediaPlayerElement.MediaPlayer.Source = MediaSource.CreateFromStorageFile(file);
       UriBox.Text = file.Path;
       // rootPage.NotifyUser("Operation cancelled.", NotifyType.ErrorMessage);

    // On small screens, hide the description text to make room for the video.
    DescriptionText.Visibility = (ActualHeight < 500) ? Visibility.Collapsed : Visibility.Visible;

脱机模式下播放受 PlayReady 保护的 fMP4

由于视频受 PlayReady 保护,屏幕截图将不能包含该视频。Since the video is under PlayReady protection, the screenshot will not be able to include the video.

概括起来,我们在 Azure 媒体服务上实现了脱机模式:In summary, we have achieved offline mode on Azure Media Services:

  • 内容转码和 PlayReady 加密可以在 Azure 媒体服务或其他工具中完成;Content transcoding and PlayReady encryption can be done in Azure Media Services or other tools;
  • 内容可以托管在 Azure 媒体服务或 Azure 存储中,用于渐进式下载;Content can be hosted in Azure Media Services or Azure Storage for progressive download;
  • PlayReady 许可证交付可以来自 Azure 媒体服务或其他位置;PlayReady license delivery can be from Azure Media Services or elsewhere;
  • 已准备好的平滑流式处理内容仍然可以通过 DASH 用作联机流式处理或作为 DRM 使用 PlayReady 进行平滑处理。The prepared smooth streaming content can still be used for online streaming via DASH or smooth with PlayReady as the DRM.

后续步骤Next steps

混合 DRM 系统设计Hybrid DRM system design