Thursday, June 7, 2012

Things to consider in video streaming


Video streaming is gaining momentum. Nowadays nobody wants to download videos and watch. Why should we download videos if we can watch them online? But nobody can enjoy a video if it's quality is bad or if it periodically pauses for buffering etc. So every system administrators must be aware of some aspects while streaming videos. In this post we will discuss main points in streaming videos. The main aspects of video streaming are resolution, encoding, frame rate, bit rate, data rate, aspect ratio and data transfer rate.

First of all lets see some video definitions :
Standard Definition :
These are the common standard definition resolutions.
480p 720x480 (Normal)
576p 720x576 (PAL)

High Definition :
720p 1280x720

Full HD :
1080p 1920x1080

Before streaming a raw video we have to encode it. Here is my suggestions for encoding a video.
Video format :
MPEG-4 (.mp4)

Video encoding:

Audio encoding:

Protocol :

Before encoding we have to decide some parameters for encoding the video. Of course, the first one is resolution of the video, here we have a few options
YouTube gives 4 different resolutions which users can select manually. 1080p, 720p, 480p and 360p (Full screen not supported).

Frame rate :
Frame rate is one of the important parameter affecting the quality of the picture. Some commonly used are 25fps(frame per second), 29.97 and 30. I recomment 30 fps.

Bit rate / Data rate
At which rate the data should be encoded. We will discuss this later in this post.

Adaptive or By user selection.
Adaptive bit rate streaming is one of the latest tecchnologies in video streaming. In this video will be encoded in many bitrates and the customer will be able to select the most suitable bitrate video depending upon his network capabilities. This can be done either automatically or manually. YouTube gives option for users to select the quality they want. Normally 1080p, 720p, 480p, 360p and 240p

Sample rate 96khz or 48khz
Channels: Stereo or Stereo + 5.1

Bits Per Pixel:
Bits per pixel is one of the most important thing affecting the picture quality. It can be calculated using the following formulae.

bits per pixel = (bit rate)/(height x width x frame rate)
For the low motion, talking head videos the BPP range of .1 to .15 will be fine.  But for the high motion videos like car race of football match .15 to .20 is required. But in my experience it has been see that if the source file is good, converted files with BPP with range even 0.7 - 0.15 does well.

For example a video encoded with 5000kbps bit rate with 1280*720 resolution @30fps
will have a bit/pixel rate of
(5000*1000)/(1280*720*30) = 0.18

Aspect ratio :
Old telivisions were using the 4:3 aspect ration. But almost all the televisions and monitors available now is using 16:9. So the later one is preferable.

Data transfer size :
Data transfer size is the most important one. It is the data trasnferred between server and clients pc while watching a video. It can be calculated using the fowllowing formulae.

Storage size (in megabytes) = length (in seconds) × bit rate (in bit/s) / (8 × 1024 × 1024)

Lets see how much data will be trasferred or bandwidth usage for watching a video for one hours.
Playing video with bit rate 8,000 kbps
3433Mb = (3600*8000*1000)/(8*1024*1024) 3.4 G/Hour

Playing video with bit rate 5,000 kbps
2145Mb = (3600*5000*1000)/(8*1024*1024) 2.2 G/Hour

Playing video with bit rate 2,500 kbps
1072Mb = (3600*2500*1000)/(8*1024*1024) 1.0 G/Hour

Playing video with bit rate 2,000 kbps
1072Mb = (3600*2000*1000)/(8*1024*1024) 860Mb/Hour

The data transfer will be same irrespective of frame(XxY) size. For different frame sizes with same bitrate, quality will differ. (Big frames will have less quality with same bitrate).

Thats all for now. Kindly share your experiences, opinions and views. For streaming videos using Amazon Cloudfront, you can read my guest post on renjusblog at streaming videos using clodfront

Recommended Reading

1. Streaming Media Bible
2. Video Over IP, Second Edition: IPTV, Internet Video, H.264, P2P, Web TV, and Streaming: A Complete Guide to Understanding the Technology
3. Mastering Internet Video: A Guide to Streaming and On-Demand Video: A Guide to Streaming and On-Demand Video

No comments:

Post a Comment

Be nice. That's all.