Encoding and Packaging
Updated: September 19, 2014
In order to deliver digital video over the internet you must compress the media. Digital video files are quite large and may be too big to deliver over the internet or for your customers’ devices to display properly. People watch videos on a variety of devices from TVs with set-top boxes, desktop PCs to tablets and smartphones. Each of these devices have different bandwidth and compression requirements. Encoding is the process of compressing video and audio using Compressor/Decompressors or codecs. The quality of encoded content is determined by the amount of data that is lost when the content is compressed and decompressed. Many factors affect the loss of data in the compression process, but in general, the more complex the original data and the higher the compression ratio, the more detail is lost in the compression process.
Once a video has been encoded it can be placed into different file containers. The process of placing encoded media into a container is called packaging. For example, you can take an MP4 file and convert it into Smooth Streaming or HLS content by using the Azure Media Packager. The following blog explains the difference between encoding and packaging: Encoding versus Packaging.
This section contains topics that describe the encoding and packaging with Media Services.
Codecs have two components: one to compress digital media files for transmission and the other to decompress digital media files for playback. There are audio codecs that compress and decompress audio and video codecs that compress and decompress video. Codecs can use lossless or lossy compression. Lossless codecs preserve all of the information when compression occurs. When the file is decompressed, the result is a file that is identical to the input media, making lossless codecs well suited to archiving and storage. Lossy codecs lose some of the information when encoding and produce smaller files (than the original) at the cost of video quality and are well suited to streaming over the internet. The two main codecs used by the Azure Media Encoder to encode are H.264 and VC-1. Other codecs may be available in our partner ecosystem of encoders.
Encoders are software or hardware that compress digital media using codecs. Encoders typically have various settings that allow you to specify properties of the media generated for example, the codecs used, file format, resolution, and bitrate. File formats are containers that hold the compressed video as well as information about what codecs were used to compress the video. Azure Media Encoder supports the formats and codecs described in the following topic: Formats Supported by the Media Services Encoder.
It is important to understand the difference between codecs and file formats. Codecs are the software that implements the compression/decompression algorithms whereas file formats are containers that hold the compressed video.
Resolution, usually measured in lines of resolution, specifies how many lines make up a full video image. Typical resolutions are 1080p and 720p for High Definition (HD), and 480p for Standard Definition (SD). The bitrate of a video is the number of bits recorded per second and is usually specified as kilobits per second (kbps). The higher the bitrate, the higher the quality of the video. A video can be encoded using a constant bitrate or variable bitrate.
In Constant Bitrate Encoding (CBR) the encoder uses a constant bitrate while encoding the entirety of a video. The amount of data needed to display a video varies as the complexity of the video varies. CBR specifies a maximum bitrate the encoder can generate. If the video being encoded requires more data, the result is poor quality video. CBR encoding is useful when you want to know the bit rate or approximate duration of a file without parsing the entire file. This is required in live streaming scenarios where the media content needs to be streamed at a predictable bit rate and with consistent bandwidth usage.
Variable bit rate (VBR) encoding is an alternative CBR. Where CBR encoding strives to maintain the bit rate of the encoded media, VBR strives to achieve the best possible quality of the encoded media.VBR encoding in general, produces a higher quality to bandwidth ratio when compared with CBR encoding. A higher bitrate is used for more complex scenes and a lower bitrate is used for less complex scenes. VBR encoding is, in general, more computation intensive and may require multiple passes while encoding video. This can result in the encoding process taking more time to complete.
Azure Media Services supports progressive download and streaming. When encoding for progressive download, you encode to a single bitrate. You can encode a video multiple times and have a collection of single bitrate files from which a client can choose. Once a client chooses a bitrate it will display the entire video at that bitrate. If network bandwidth decreases or CPU utilization on the client device spikes, playback of the video may temporarily pause while buffering enough data to continue.There are two types of streaming available: single bitrate streaming and adaptive bitrate streaming. With single bitrate streaming a video is encoded to a single bitrate stream and divided into chunks. The stream is delivered to the client one chunk at a time. The chunk is displayed and the client requests the next chunk. When encoding for single bitrate streaming, you can encode to a number of different bitrate streams and the client application can choose the stream to download. Like progressive download, once the client chooses a stream it uses that same bitrate to display the entire video.
The other type of streaming is adaptive bitrate streaming. When encoding for adaptive bitrate streaming you encode to a MP4 bitrate set which creates a number of different bitrate streams. These streams are broken into chunks like single bitrate streaming. But with adaptive bitrate streaming the client can switch to a higher or lower bitrate stream as the video is displayed based on the current network bandwidth, CPU utilization, and other factors. Azure Media Services supports three adaptive bitrate streaming technologies:
HTTP Live Streaming (HLS) - an adaptive bitrate protocol created by Apple
Smooth Streaming - an adaptive bitrate protocol created by Microsoft
MPEG DASH – an adaptive bitrate protocol that has been approved as an international ISO standard
Formats Supported by the Media Services Encoder – Discusses the file and stream formats supported by Media Services
Encoding with Azure Media Encoder – Describes how to encode a video
Controlling Media Service Encoder Output Filenames – Describes the file naming convention used by the Azure Media Encoder and how to modify the output filenames
Encoder Guides- A collection of topics that help you determine the best encoding for your intended audience
Encoding your media with Dolby Digital Plus – Describes how to encode audio tracks using Dolby Digital Plus encoding
Dynamic Packaging – Describes how to encode to a single format and dynamically serve Smooth Streaming, Apple HLS, or MPEG-DASH
Quotas and Limitations – Describes quotas used and limitations of the Media Services Encoder
Advanced Encoding Topics – Describes advanced encoding topics