视频播放Video playback

建议的读前准备Suggested pre-reading

概述Overview

可以使用媒体图将视频记录到 Azure 媒体服务资产中。You can use media graphs to record video into an Azure Media Services asset. 在本文档中,你可以了解使用 Azure 媒体服务的现有流式处理功能播放资产所需采取的步骤。In this document, you can learn about the steps you need to take in order to play an asset using existing streaming capabilities of Azure Media Services.

流式处理终结点Streaming endpoint

你可以使用 Azure 媒体服务通过行业标准的基于 HTTP 的媒体流式处理协议(例如 HTTP Live Streaming (HLS) 和 MPEG-DASH)将资产流式传输到视频播放器。You can use Azure Media Services to stream the asset to video players using industry-standard, HTTP-based media streaming protocols like HTTP Live Streaming (HLS) and MPEG-DASH. 媒体从录制内容到流式处理格式的这种转换由流式处理终结点处理,这是你需要在 Azure 媒体服务帐户中提供的资源。This conversion of media from recorded content into streaming formats is handled by a streaming endpoint, which is a resource that you need to provision in your Azure Media Service account.

流式处理策略Streaming policy

Azure 媒体服务为你提供了多种方法来保护视频流,如使用媒体服务动态加密保护内容一文中所述。Azure Media Services offers you different methods to secure your video streams, as discussed in Protect your content with Media Services dynamic encryption article. 内容保护的选项大致包括:At a high level, options for content protection are:

  • 明文流式处理 - 流式处理期间不应用加密。In-the-clear streaming – where no encryption is applied during streaming.
  • 使用高级加密标准 (AES-128) - 并实现一种方法,将仅用于解密视频的密钥传递给经过身份验证的观看者。Use Advanced Encryption Standard (AES-128) – and implement a method to deliver the keys for decrypting the video only to authenticated viewers.
  • 使用数字版权管理 (DRM) 系统 - 控制实施这些策略的设备对视频的使用、修改和交付。Use Digital Rights Management (DRM) systems – to control the use, modification, and delivery of video to devices that enforce these policies.

若要实现内容保护,你可以在媒体服务帐户中定义并创建流式处理策略,并将其用于流式处理所有资产(假设所有流都具有相同的安全性要求)。To achieve content protection, you can define and create a Streaming Policy in your Media Service account, and use it for streaming all assets (assuming all streams have the same requirements for security). 你也可以使用任何预定义的策略(例如 Predefined_ClearStreamingOnly)。You can also use any of the predefined policies (such as Predefined_ClearStreamingOnly).

流式处理定位符Streaming locator

在媒体服务帐户中启动流式处理终结点并定义流式处理策略后,可以继续通过 HLS 或 DASH 协议从资产中流式传输录制的媒体。Once you have a Streaming Endpoint started in your Media Service account, and streaming policy defined, you can proceed to stream recorded media from an asset via HLS or DASH protocols. Web 播放器和移动应用需要指向该 HLS 或 DASH 流的 URL。Web-players and mobile apps need a URL pointing to that HLS or DASH stream. 你可以使用流式处理定位符生成此 URL。You can build this URL using the streaming locator. 如本文中所述以及创建流式处理定位符并生成 URL 示例中显示,流式处理 URL 由流式处理终结点、流式处理策略和流式处理定位符组成。As discussed in that article, and shown in Create a streaming locator and build URLs sample, the streaming URL is composed out of the streaming endpoint, streaming policy, and the streaming locator.

使用文件接收器记录的内容Content recorded using file sink

媒体图文件接收器中所述,你可以通过媒体图中的文件接收器使用媒体图将视频录制到边缘设备的本地文件系统中。As described in media graph file sink, you can use media graphs to record videos to the local file system of the edge device using a file sink in your media graph. 文件接收器生成 MP4 文件,可以使用 HTML5 <video> 元素来播放此类内容。The file sink generates MP4 files, and you can use the HTML5 <video> element to play such content.

后续步骤Next steps

Azure IoT EdgeAzure IoT Edge