Thursday, September 4, 2014

How to stream better quality video: Part 2 - Adaptive streaming

by Iain Richardson and Abharana Bhat
You want to stream a video clip to several customers. One customer has a high bandwidth leased line connection, while another is trying to view your clip on a mobile device using a poor-quality 3G signal. How do you make sure they each get the best possible video quality? Adaptive streaming may be the answer.

Video streaming sends your video (source) to play back on a computer or mobile device (client), using an internet connection to transport the video. Streaming video is a complex process involving many different components. In this series of articles, we help you understand the basics of streaming video and the various factors that can make a big difference to the quality of your video clip.

In our first article, we looked at the basics of streaming video and discussed good and bad practice. In this article, we look at how to stream video effectively over networks with varying connection speeds.


1. Adaptive streaming: the basics


The general concept of adaptive streaming is shown in Figure 1.

a. Multiple versions:

Starting with a high quality video source such as a High Definition video clip, a video encoder produces versions at multiple qualities and bitrates, for example:

  1. An HD version at 2Mbps 
  2. A Standard Definition (SD) version at 1Mbps 
  3. A very low resolution version at 50kbps. 

Each of these versions is split into small chunks, typically each a few seconds long, and stored on a web server ready for streaming.

b. Index file:

The server maintains an index or playlist file which lists all the media chunks, including the bitrate of each stream and the starting position of each chunk.

c. Streaming to the client:

When the client (the user's software application) requests playback of the video stream, the server returns the index file to the client.

The client requests chunks at the most suitable bitrate, based on considerations such as the available connection bandwidth, playback delay and device capabilities. The server sends each requested chunk in order.

The result: video and audio playback that adapts to suit the network conditions.


2. Examples
Example 1:

The client is initially connected to the internet via a good quality WiFi connection. Streaming starts at 2Mbps and the user sees good quality, HD video with low delay.

The WiFi signal is lost and the client switches to a 3G mobile connection. Streaming switches to 1Mbps, then to 50kbps. The user sees continuous video playback. The video quality steps down to SD then to lower resolution because of the drop in network bandwidth.

Example 2:

The client is configured to start playback as quickly as possible. It automatically requests the lowest quality stream and steps up if the bandwidth is good enough. The user sees basic quality playback very soon after pressing "play". After a few seconds, the video quality improves progressively without any delays or breaks in playback.

Example 3:

Click the link below and play each video to see adaptive streaming in action. Click on the "HD" button on the player to select one of 5 different bitrates, or select "Auto" to allow the stream to adapt according to your network connection.





3. Practical considerations
Adaptive streaming format. There are a number of choices of adaptive streaming methods, including:

Each of these methods has pros and cons. When selecting an adaptive streaming technology, it is important to consider:
  • Availability and cost of encoding software tools 
  • Compatibility with your target clients. 
Stream count. How many streams should be created for each video file? More streams will give the client more flexibility to choose the best stream based on the available bitrate and display capabilities. However, each stream needs to be converted (transcoded) from the original and stored on a server. This may increase computing and storage costs.

Chunks and key frames. How many seconds per chunk? Each chunk starts with a key frame, i.e. a video frame encoded without any prediction from other frames. Key frames require significantly more bit rate to transmit than predicted ("inter") frames. Smaller chunks make it possible for the client to switch streams more frequently, leading to faster startup and smoother adaptation. However, smaller chunks require more frequent key frames, leading to poorer transmission efficiency. A good compromise may be to use smaller chunks early in the video stream, increasing the size later on.


4. Going further Part 3 in this series will compare the latest video codecs in depth.

Copyright (c) Vcodex Limited / Onecodec Limited, 2014

No comments: