About Video for the Web

Following up with our article on Streaming Live video on the web we now want to take a look at simply putting video footage online to share with the world. There are a lot of options when you are simply allowing viewers to download your footage. So let’s take a look at some of them and what they can do.

Codecs for All – Choose your Audience

One of the first things that you will want to do is to pick a codec or even multiple codecs to encode the video into. There are a large range of video codecs on the market today which each has their own strengths and weaknesses.

Commonly used online video codecs:

  • WMV
  • MPEG4-ASP(DivX, Xvid)
  • H.264
  • Flash (H.263 Sorenson Spark)
  • On2 VP6

*In another article we will discuss the pros and cons of each of these codecs

The video codecs are the compressors of the video information in your file. In general when uploading a video to the web you want it to be the smallest file size possible while maintaining as much of the original video quality as possible. In this case we use a “lossy” codec. This means that we take the information in the file and use computations to reduce the amount of data needed to describe each frame of video. In doing so there is some amount of loss of quality that can never be recovered but the file size is reduced greatly. Some codecs do a better job at keeping quality at small file sizes, but this generally incurs a performance penalty on older machines. File size is important because the larger your files the more disk space and bandwidth they will use. If you have a popular file it can quickly consume your bandwidth allotment and cause an overage on your account which can cost a lot of money. Compressing your video files with a lower resolution and decent bit rate will often result in a better image quality and smaller file size.

The next consideration for codecs is will your audience be able to play the files with a default setup or will they need to install some extra software in order to watch your video. It is an important thing to consider and it really helps if you know your audience. If most visitors to your website are on a Mac or Linux you probably will want to use H.264 in a Quicktime container. Likewise if your audience is all Windows based you might want to use a WMV9 codec so they can play the file with the default install of windows. Adobe Flash is a popular option that has the highest install base (98% as of Flash 7 and increasing each month) on Windows, Mac, and Linux that can allow video to be played in the web browser, but there are some limitations regarding hardware acceleration of video which can potentially affect performance as well as user interface inconsistencies among the various Flash video players available.

Calculating the Bitrate

Bit rate is the key to file size and download times. As a general rule of thumb two things happen with higher bitrates. The image and audio quality increases, as well as the file size. One of these rules is broken each time a newer, superior codec is released. The quality of a new codec can be equal to an older codec with a lower bitrate in most cases. With a lower bitrate a newer codec could afford you to have a smaller file that looks the same but if you encode the file at the same bit rate the file size always be the same size.

To calculate the file size you need to know the video duration and the video/audio bitrate you want to use.

Sample File Info:

  • File Length: 10 Minutes (600 seconds)
  • Video Bitrate: 500 kbit/s
  • Audio Bitrate: 128 kbit/s
  • Total Bitrate: 628 kbit/s

With this info we can calculate roughly what the file size will be. Our total bitrate is 628K kbit/s combining the video and audio. Each second of video weighs in at 628 kbits. One kbit, or kibibit, is 1024 * 8 or 8192 binary digits. If we divide by 8 we will get a total of 78.5 KiB (Kibibytes, most commonly and mistakenly referred to as kilobytes) a second. Multiply this by the duration in seconds (10 minutes * 60 seconds per minute = 600 seconds) and you get 47100 KiB. If you want the size in MiB divide that number by 1024 (1024 KiB = 1 MiB) for a total of 45.9 MiB for a 10 minute file at a bitrate of 628 kbits a second. The other useful bit of information we got was that if someone wanted to watch this file while it was being downloaded without having to wait for buffering (progressive download [more on that later]) they would need a connection that could download at 78.5 KiB or faster. This would work for most broadband connections, but depending on your customer base or intended audience they may have slower connections, such as those limited to 30 KiB/s download speeds.

Containing the Data

Now that we have the video and audio compressed with our new codecs we need something to hold them for delivery. Most windows users will recognize these by the file extensions.

Common File Containers:

These containers are responsible for syncing the data from the video and audio streams so they play back together correctly. Some containers are also capable of storing additional information such as meta data or subtitles. Most containers are also capable of containing a number of possible codecs so it is important to realize that just because the file extension is .mov it could be one of many codecs used.

Progressive or not Progressive

The next thing you need to decide is if you want to provide your videos as a file that is downloaded and then viewed or viewed as it is downloading. The second option is called progressive downloading. Progressive downloads are similar in nature to streaming video but it depends on what client is used and the server setup on whether you can get all the features you normally would with a true streaming setup. With progressive downloads and properly formated video files you can allow your audience to start watching almost instantly, neatly bypassing expensive or difficult to setup true streaming solutions. It also can be setup to allow them to randomly access the file, that is seek to any point in the file without loading the whole file and play from that point onward. These are usually the two most sought after features of streaming services which can be done with a simple web server and a PHP script or server plugin, such as the H.264 streaming plugin for lighttpd.

Progressive downloads are a great tool to allow people to watch your content quickly on your website. It also brings them back if they want to see it again. This allows for repeat visitors as well as more options to increase ad revenu if you use it. The down side is that depending on cache settings a single user who watches your videos time and time again will consume more bandwidth which can increase your costs.

If you allow your viewers to save the content directly to their computers they can then watch it as often as they want without using additional bandwidth. The trade off obviously is that you will not get the increased traffic to your site.

Each method has its pros and cons which must be considered when selecting a solution for your website and audience.

Summing it all up

The world of online video is constantly evolving with updates, new codecs, and delivery methods. The key is to make sure you use the right options based on your audience. When you base your choices on your audience you will be more successful in delivering your content to them.