Κοινή χρήση μέσω


1 - Introduction to Microsoft Azure Media Services

patterns & practices Developer CenterDownload Reference ImplementationDownload book

Traditionally, building the workflow for the creation, management, and distribution of media is problematic. It involves having to integrate multiple technologies and providers, some of which may be incompatible. In addition, it can require a huge investment in infrastructure, which may not always be fully utilized. These issues can result in a non-standardized workflow that is not easily scaled, and that requires coordination at different stages of the workflow.

This chapter introduces Microsoft Azure Media Services, and discusses the typical Media Services workflow.

What is Microsoft Azure Media Services?

Azure Media Services allows you to build scalable, cost effective, end-to-end media distribution solutions that can upload, encode, package, and stream media to Windows, iOS, Android, Adobe Flash, and other devices and platforms.

The benefits that Media Services offers over the traditional approach to building a media workflow are as follows:

  • An API that allows developers to easily create, manage, and maintain custom media workflows.
  • A standardized workflow that improves coordination and productivity when there are multiple participants involved in the creation and management of content.
  • Automatic scalability by using global data centers to transcode and deliver media assets, without having to plan for capacity spikes or worry about idle datacenters.
  • Cost effectiveness by encoding media once, and then using dynamic packaging to deliver it in multiple formats.

Media Services provides everything you'll need to easily build and operate the three standard media solutions:

  • Video-on-demand (VOD) services. Media Services provides everything you'll need to operate VOD services to multiple devices and platforms, including all the tools and services you'll need to handle media processing, delivery, and consumption.
  • Online video platforms (OVP). Media Services will integrate with your OVP and Content Management System (CMS) to help your platform gain scale by using the global footprint of Azure datacenters, without having to plan for capacity spikes or worry about idle datacenters.
  • End-to-end solutions. Media Services can be used to easily build secure end-to-end media workflows entirely in Azure, from content ingestion through to encoding, packaging, and protection. This helps to reduce the costs that are associated with integrating multiple products and providers.

Regardless of your development scenario, the first step in sharing video content is to choose your media experience.

To see how companies are using Media Services to stream video to their customers, read the following case studies.

  • all3media

  • blinkbox

  • Xbox

    Choosing your Azure Media Services video experience

    The first step in sharing video content is deciding what type of experience you want your users to have. This can be answered by asking a number of questions:

    • How will your users be viewing the video content?
    • Will your users be connected to the internet?
    • Will your users expect the video content to be in HD?
    • Will your users be viewing the video content on a computer or a hand-held device?

Providing answers to these questions will help to give your users the best possible experience.

Another decision that must be made is the type of viewing devices that you will support. The following table outlines the viewing devices supported by Media Services, and the recommended viewing approaches for those devices.

Device

Description

Recommended viewing approaches

Web browsers

Web browsers can be run on desktop PCs, smart phones, and tablets. When running on desktop PCs you can take advantage of the large screen size and the large storage capacity, allowing you to stream HD videos.

Offline viewing, progressive downloading, and streaming.

Smart phones

Smart phones have small screens and small storage capacities.

Streaming.

Tablets

Tablets have larger screens than smart phones, but still typically have smaller storage capacity.

Streaming. Tablets with larger storage capacities can take advantage of offline viewing and progressive downloading.

Xbox

Xbox consoles have the benefit of large screens and large storage capacity.

Offline viewing, progressive downloading, and streaming.

Set-top boxes and connected TVs

These devices typically have large screens but minimal storage capacity.

Streaming.

Organizing the Azure Media Services video processing workflow

The following figure shows a high-level overview of the standard workflow used when processing media with Media Services.

A high-level overview of the standard Media Services workflow

A high-level overview of the standard Media Services workflow

Media Services supports on-demand media and live streams workflows. However, the live streams workflow is outside the scope of this guide. Therefore, the guide focuses on the on-demand media workflow.

The steps involved in the workflow are as follows:

  1. Media is uploaded to Media Services and stored in Azure Blob Storage. service
  2. Uploaded media is encoded using the Azure Media Encoder, with the encoded media being stored in Azure Storage.
  3. Encoded media is packaged by the Azure Media Packager, with the result being stored in Azure Storage.
  4. Client applications playback the media located at a URL, with the Origin Service processing the outbound stream from storage to client application.

Therefore, the typical Media Services workflow can be summarized as:

  1. Media upload
  2. Media processing
  3. Delivery
  4. Consumption

Each item will now be discussed in turn.

Uploading video into Azure Media Services

You must upload your content into Azure Media Services in order to be able to encode, manage, and consume it. Media Services uses Azure Storage to store your media for processing and viewing. Your content can be programmatically uploaded using the Media Services REST API or one of the available client SDKs. These APIs allow you to upload one file at a time or perform bulk upload operations. Media Services also allows you to perform secure uploading and storage of your content. Storage encryption will encrypt your content locally prior to uploading it to Azure Storage where it will be stored in an encrypted form.

The fundamental content in Media Services is an asset. An asset contains one or many files, such as video, audio, closed caption files, and metadata about the files. Each asset contains one or more asset files, with each asset file containing metadata about a specific media file. Once an asset has been created by uploading files it can be used in Media Services workflows such as encoding and streaming.

Each asset is mapped to a blob container in an Azure Storage account, with the files in the asset being stored as blobs in the container. A blob container groups a set of blobs, just as a folder groups a set of files. They are used in Media Services as a boundary point for access control. An Azure Storage account can contain an unlimited number of blob containers and a container can store an unlimited number of blobs.

Media Services accounts are associated with one or more Azure Storage accounts. Each account can contain an unlimited number of blob containers, and is only subject to the limits on the underlying account. Media Services provides SDK tooling to manage multiple storage accounts and perform load balancing of the distribution of assets during upload. For more information see "Managing assets across multiple storage accounts in Azure Media Services and defining load balancing strategy."

For more information about uploading content, see "Chapter 3 – Uploading Video."

Supported file types in Azure Media Services

Various video, audio, and image file types can be uploaded to a Media Services account, with there being no restriction on the types or formats of files that you can upload using the Media Services SDK. However, the Azure Management portal restricts uploads to the formats that are supported by the Azure Media Encoder. These import formats include MPEG-1, MPEG-2, MPEG-4, and Windows Media Video encoded video, MP3, WAVE, and Windows Media Audio encoded audio, and BMP, JPEG, and PNG encoded images. The Azure Media Encoder can export data as Windows Media Video, Windows Media Audio, MP4, and Smooth Streaming File Format.

For more information about the supported file formats see "Supported input formats" and "Introduction to encoding."

Processing media with Microsoft Azure Media Services

In Media Services, media processing involves obtaining a Media Processor instance, encoding, packaging, and protecting media files.

Obtaining a media processor instance

Media Services provides a number of media processors that enable video to be processed. Media processors handle a specific processing task, such as encoding, format conversion, encrypting, or decrypting media content. Encoding video is the most common Media Services processing task, and it is performed by the Azure Media Encoder.

Encoding video

Encoding is the process of taking a video and turning it into a format that can be consumed by users. Users could be using a variety of devices to watch your videos, including desktop computers, smart phones, tablets, Xbox consoles, set-top boxes, or Internet-connected TVs. These devices all have features that affect the required encoding. For instance, smart phones have small screens and little storage, while desktop computers have larger screens and larger storage. In addition, smart phones potentially have a more limited bandwidth than desktop computers. Therefore, when you choose how to encode a video you must bear in mind the variety of devices that users will consume the video on.

Note

In some cases you may want to have multiple encodings to enable the best possible experience on a range of devices.

The Media Encoder is configured using encoder preset strings, with each preset specifying a group of settings required for the encoder. Encoder presets are divided into two groups – general presets and device specific presets. Videos encoded with general presets can be used by any device that supports the required file formats. Videos encoded with device specific presets are designed to be used by a specific device, such as a smart phone. For a list of all the presets see "Appendix B –Azure Media Encoder Presets."

Encoding for a smart phone

When encoding video for a smart phone you should choose an encoding preset that matches the resolution, supported codecs, and supported file formats of the target device. For example, for a Windows Phone that supports H.264 video up to 1080p you should use the "H264 Smooth Streaming Windows Phone 7 Series" preset.

Note

Different smart phones, even those from the same company, can support different resolutions, bit rates, codecs, and file formats.

The iPhone 5 supports H.264 video up to 1080p in HLS format. However, Media Services does not support encoding video directly into HLS but you can encode to MP4 and then use static packaging to convert the video to HLS. Alternatively, you can encode to Smooth Streaming or MP4 and use dynamic packaging to convert the video to HLS in real-time. Therefore, if you wanted to encode video to 1080p for an iPhone 5 you would use the "H264 Adaptive Bitrate MP4 Set 1080p for iOS Cellular Only" preset. Similarly, for an Android phone that supports H.264 video at 480x360 you could use the "H264 Adaptive Bitrate MP4 Set SD 4x3 for iOS Cellular Only" preset. Then dynamic packaging would be used to convert the video to HLS in real-time.

Encoding for Xbox

When encoding video for Xbox you can choose between VC-1 and H.264 smooth streaming at resolutions up to 1080p. For example, to encode a video to 720p using H.264 you would use the "H264 Smooth Streaming 720p Xbox Live ADK" preset.

Encoding for other devices and platforms

General presets can be used to encode for a variety of devices including desktop machines, tablets, and set-top boxes. To choose the appropriate encoding preset you must determine how users will view your content, and what resolutions, bit rates, codecs, and file formats are supported on their viewing devices.

The following table lists each type of device and the client technologies supported by Media Services.

Device

Technologies

Windows 8

Smooth streaming, progressive downloading, MPEG-DASH.

Windows RT

Smooth streaming and progressive downloading.

Windows Phone

Smooth streaming and progressive downloading.

Web browsers

Smooth streaming is supported through additional SDKs and Player Frameworks provided by Microsoft.

Progressive download is supported in browsers through the HTML5 video element.

Internet Explorer 11 and Chrome both support MPEG-DASH through the use of Media Source Extensions (MSE).

Xbox

Smooth streaming and progressive downloading.

Macintosh

Apple HLS and progressive download.

iOS

Smooth streaming, Apple HLS, and progressive downloading.

Android

Smooth streaming, progressive downloading, and Apple HLS.

Set-top box, connected TVs

Smooth streaming, progressive downloading, and Apple HLS.

For more information about encoding media with Media Services see "Chapter 4 – Encoding and Processing Video."

Packaging video with Azure Media Services

Once a video has been encoded it is placed in an output asset, which can then be placed into a variety of file containers. This process is referred to as packaging. For example, you could convert an MP4 file into smooth streaming content by using the Azure Media Packager to place the encoded content into a different file container.

Note

Packaging does not re-encode a video. Instead, it rearranges the encoding and places it in a different file container.

Media Services allow the user to decide if they will package video upfront with a media processor, known as static packaging, or package video on demand, known as dynamic packaging.

The Azure Media Packager is a media processor capable of performing static packaging. Static packaging involves creating a copy of your content in each format required by users. For example, an MP4 file could be converted into smooth streaming content if both formats are required by users. This would result in two copies of the content existing, each in a different format.

Dynamic packaging is not performed by a media processor, but by origin servers. An origin server packages the source media when a client application requests a specific video format, allowing you to encode your video just once, with it being converted in real time to the format requested by the client application. With dynamic packaging your video is typically stored as an adaptive bitrate MP4 file set. When a client application requests the video it specifies the required format. The origin server then converts the MP4 adaptive bitrate file to the format requested by the client in real time. This ensures that only one copy of your video has to be stored, therefore reducing the storage costs.

Dynamic packaging is the preferred method for publishing a video. For more information see "Dynamic packaging."

Protecting video with Azure Media Services

To protect your media when it is published, Media Services supports PlayReady sample-based Common Encryption and AES 128-bit CBC Envelope Encryption. PlayReady is a Digital Rights Management (DRM) system developed by Microsoft. DRM allows you to control who has access to your content. When a user tries to watch PlayReady protected content, the client application requests the content from Media Services. Media Services then redirects the client to a licensing server that authenticates and authorizes the user’s access to the content. The client application can then safely download the decryption key which will allow the content to be decrypted and viewed.

AES Envelope Encryption provides content encryption, but does not allow sophisticated digital rights management, or secure key delivery (which is provided only by SSL). Content owners should trust their clients if they choose AES 128-bit Envelope Encryption. It is much easier for an untrusted, malicious end user to acquire and redistribute keys.

For more information about content protection see "Protecting Assets with Microsoft PlayReady."

Delivering video from Azure Media Services

Media Services provides different mechanisms for delivering media assets that have been uploaded to Media Services. It can be used to deliver content that has simply been stored in Media Services, or it can also include content that has been processed or encoded in different ways.

There are typically four approaches that users can use to access videos:

  1. Offline viewing
  2. Progressive downloading
  3. Streaming
  4. Adaptive bitrate streaming

Offline viewing involves a user downloading an entire video onto their computer or device. Because videos can be quite large, it may take some time for the download to complete, and the device must have enough storage space to hold the entire video. However, the benefit of this approach is that you do not need a network connection to view the video once it has been downloaded.

Progressive downloading allows a user who is connected to the internet to start viewing a video before the entire video has been downloaded. However, it does require that the viewing device has enough storage space to hold the entire video.

Streaming also requires an internet connection, but differs from progressive downloading in that it only downloads a small amount of the video at once and discards it once it has been displayed. The benefit of this approach is that it requires little storage on the viewing device.

Adaptive bitrate streaming allows client applications to determine network conditions and adapt the data rate of the video content to the available network bandwidth. When network communication degrades, the client can automatically select a lower bitrate version of the content, therefore allowing the user to continue viewing the video, albeit at a lower quality. When network conditions improve the client can automatically switch back to a higher bitrate with improved video quality. The benefit of this approach is that the video player can automatically react to changes in bandwidth during playback, therefore providing a better user experience.

Note

Some adaptive bitrate streaming technologies, such as Smooth Streaming, also monitor video rendering performance in order to determine the appropriate bitrate stream for the client.

Media Services supports three adaptive bitrate streaming technologies:

  1. Smooth Streaming. This is an adaptive bitrate streaming technology developed by Microsoft.
  2. HTTP Live Streaming (HLS). This is an adaptive bitrate streaming technology developed by Apple.
  3. MPEG DASH. This is an adaptive bitrate streaming protocol created by the Motion Picture Experts Group (MPEG), and is an international standard.

Processing outbound video from Azure Media Services

The Media Services Origin Service handles requests for content. It retrieves files from Azure Storage and provides them to Content Delivery Networks (CDN) or client applications directly. The origin servers have features that allow them to respond to several hundred requests per second, and provide dynamic encryption and dynamic packaging services.

Providing access to video within Azure Media Services

Accessing content in Media Services requires a locator, which provides an entry point to access the files contained in an asset. An access policy is used to define the permissions and duration that a client has access to a given asset. Multiple locators can share an access policy so that different locators can provide different start and stop times while all using the same permission and duration settings provided by the access policy.

There are two types of locators:

  1. Shared access signature locators
  2. On-demand origin locators

A shared access signature locator grants access rights to the underlying blob container of the media asset in Azure Storage. By specifying a shared access signature, you can grant users who have the URL access to a specific resource for a specified period of time. You can also specify what operations can be performed on a resource that’s accessed via a shared access signature locator.

Note

Media Services enables the authoring of shared access signature locators to simplify complex workflows. However, it is not expected that end-users will consume these except in special cases.

An on-demand origin locator should be used to grant access to streaming content. On-demand origin locators are exposed by the Media Services Origin Service, which pulls the content from Azure Storage and delivers it to the client. The on-demand origin locators obfuscate the underlying asset's blob container and storage account URL. Instead, they always point to a Media Services Origin Service, therefore allowing advanced scenarios such as IP restriction, cache control, and CDN authentication.

For more information about the Media Services Origin Service see "Origin Service."

Consuming video from Azure Media Services

Media Services provides support for creating media player applications that run on different devices and platforms including PCs, Macintosh, Windows Phone, iOS devices, and Android devices. Microsoft also provides many different SDKs and player frameworks that allow you to create applications that consume streaming media from Media Services. For more information see "Developing Azure Media Services Client Applications."

Summary

Media Services provides everything you'll need to build and operate video-on-demand services to multiple devices and platforms, including all the tools and services you'll need to handle media processing, delivery, and consumption. In addition, Media Services will integrate with content management systems to help your platform scale by using the global footprint of Azure datacenters, without having to plan for capacity spikes or worry about idle datacenters. Together, this helps to reduce the costs that are associated with integrating multiple products and providers when building a media solution.

More information

Next Topic | Previous Topic | Home | Community