Encoding with Media Services

The term encoding in Media Services applies to the process of converting files containing digital video and/or audio from one standard format to another, with the purpose of (a) reducing the size of the files, and/or (b) producing a format that is compatible with a broad range of devices and applications. This process is also referred to as video compression, or transcoding. See the Data compression and the What Is Encoding and Transcoding? for further discussion of the concepts.

Videos are typically delivered to devices and applications by progressive download or through adaptive bitrate streaming.

  • To deliver by progressive download, you can use Azure Media Services to convert a digital media file (mezzanine) into an MP4 file, which contains video that has been encoded with the H.264 codec, and audio that has been encoded with the AAC codec. This MP4 file is written to an Asset in your storage account. You can use the Azure Storage APIs or SDKs (for example, Storage REST API or .NET SDK) to download the file directly. If you created the output Asset with a specific container name in storage, use that location. Otherwise, you can use Media Services to list the asset container URLs.
  • To prepare content for delivery by adaptive bitrate streaming, the mezzanine file needs to be encoded at multiple bitrates (high to low). To ensure graceful transition of quality, as the bitrate is lowered, so is the resolution of the video. This results in a so-called encoding ladder – a table of resolutions and bitrates (see auto-generated adaptive bitrate ladder). You can use Media Services to encode your mezzanine files at multiple bitrates – in doing so, you will get a set of MP4 files, and associated streaming configuration files, written to an Asset in your storage account. You can then use the Dynamic Packaging capability in Media Services to deliver the video via streaming protocols like MPEG-DASH and HLS. This requires you to create a Streaming Locator and build streaming URLs corresponding to the supported protocols, which can then be handed off to devices/applications based on their capabilities.

The following diagram shows the workflow for on-demand encoding with dynamic packaging.

Dynamic Packaging

This topic gives you guidance on how to encode your content with Media Services v3.

Transforms and jobs

To encode with Media Services v3, you need to create a Transform and a Job. The transform defines a recipe for your encoding settings and outputs; the job is an instance of the recipe. For more information, see Transforms and Jobs

When encoding with Media Services, you use presets to tell the encoder how the input media files should be processed. For example, you can specify the video resolution and/or the number of audio channels you want in the encoded content.

You can get started quickly with one of the recommended built-in presets based on industry best practices or you can choose to build a custom preset to target your specific scenario or device requirements. For more information, see Encode with a custom Transform.

Starting with January 2019, when encoding with Media Encoder Standard to produce MP4 file(s), a new .mpi file is generated and added to the output Asset. This MPI file is intended to improve performance for dynamic packaging and streaming scenarios.

Note

You should not modify or remove the MPI file, or take any dependency in your service on the existence (or not) of such a file.

Creating job input from an HTTPS URL

When you submit Jobs to process your videos, you have to tell Media Services where to find the input video. One of the options is to specify an HTTPS URL as a job input. Currently, Media Services v3 does not support chunked transfer encoding over HTTPS URLs.

Examples

Creating job input from a local file

The input video can be stored as a Media Service Asset, in which case you create an input asset based on a file (stored locally or in Azure Blob storage).

Examples

Encode a local file using built-in presets

Creating job input with subclipping

When encoding a video, you can specify to also trim or clip the source file and produce an output that has only a desired portion of the input video. This functionality works with any Transform that is built using either the BuiltInStandardEncoderPreset presets, or the StandardEncoderPreset presets.

You can specify to create a Job with a single clip of a video on-demand or live archive (a recorded event). The job input could be an Asset or an HTTPS URL.

Tip

If you want to stream a sublip of your video without reencoding the video, consider using Pre-filtering manifests with Dynamic Packager.

Examples

See examples:

Built-in presets

Media Services currently supports the following built-in encoding presets:

BuiltInStandardEncoderPreset

BuiltInStandardEncoderPreset is used to set a built-in preset for encoding the input video with the Standard Encoder.

The following presets are currently supported:

  • EncoderNamedPreset.AACGoodQualityAudio - produces a single MP4 file containing only stereo audio encoded at 192 kbps.
  • EncoderNamedPreset.AdaptiveStreaming (recommended). For more information, see auto-generating a bitrate ladder.
  • EncoderNamedPreset.ContentAwareEncodingExperimental - exposes an experimental preset for content-aware encoding. Given any input content, the service attempts to automatically determine the optimal number of layers, appropriate bitrate and resolution settings for delivery by adaptive streaming. The underlying algorithms will continue to evolve over time. The output will contain MP4 files with video and audio interleaved. For more information, see Experimental preset for content-aware encoding.
  • EncoderNamedPreset.H264MultipleBitrate1080p - produces a set of 8 GOP-aligned MP4 files, ranging from 6000 kbps to 400 kbps, and stereo AAC audio. Resolution starts at 1080p and goes down to 360p.
  • EncoderNamedPreset.H264MultipleBitrate720p - produces a set of 6 GOP-aligned MP4 files, ranging from 3400 kbps to 400 kbps, and stereo AAC audio. Resolution starts at 720p and goes down to 360p.
  • EncoderNamedPreset.H264MultipleBitrateSD - produces a set of 5 GOP-aligned MP4 files, ranging from 1600kbps to 400 kbps, and stereo AAC audio. Resolution starts at 480p and goes down to 360p.
  • EncoderNamedPreset.H264SingleBitrate1080p - produces an MP4 file where the video is encoded with H.264 codec at 6750 kbps and a picture height of 1080 pixels, and the stereo audio is encoded with AAC-LC codec at 64 kbps.
  • EncoderNamedPreset.H264SingleBitrate720p - produces an MP4 file where the video is encoded with H.264 codec at 4500 kbps and a picture height of 720 pixels, and the stereo audio is encoded with AAC-LC codec at 64 kbps.
  • EncoderNamedPreset.H264SingleBitrateSD - produces an MP4 file where the video is encoded with H.264 codec at 2200 kbps and a picture height of 480 pixels, and the stereo audio is encoded with AAC-LC codec at 64 kbps.

To see the most up-to-date presets list, see built-in presets to be used for encoding videos.

To see how the presets are used, check out Uploading, encoding, and streaming files.

StandardEncoderPreset

StandardEncoderPreset describes settings to be used when encoding the input video with the Standard Encoder. Use this preset when customizing Transform presets.

Considerations

When creating custom presets, the following considerations apply:

  • All values for height and width on AVC content must be a multiple of 4.
  • In Azure Media Services v3, all of the encoding bitrates are in bits per second. This is different from the presets with our v2 APIs, which used kilobits/second as the unit. For example, if the bitrate in v2 was specified as 128 (kilobits/second), in v3 it would be set to 128000 (bits/second).

Customizing presets

Media Services fully supports customizing all values in presets to meet your specific encoding needs and requirements. For examples that show how to customize encoder presets, see:

Examples

Preset schema

In Media Services v3, presets are strongly typed entities in the API itself. You can find the "schema" definition for these objects in Open API Specification (or Swagger). You can also view the preset definitions (like StandardEncoderPreset) in the REST API, .NET SDK (or other Media Services v3 SDK reference documentation).

Scaling encoding in v3

To scale media processing, see Scale with CLI.

Ask questions, give feedback, get updates

Check out the Azure Media Services community article to see different ways you can ask questions, give feedback, and get updates about Media Services.

Next steps