Best Practices for Windows Media Encoding

2-Pass Bit Rate VBR (Constrained)
2-pass bit rate VBR (constrained) is the optimal encoding mode for when the playback environment can handle a peak bit rate higher than the average bit rate. This is typical of content that is distributed as files instead of streams, be it off a web server or a file on a disc. Almost every web video WMV file not targeted to run on Windows Media Services should be using Constrained VBR.

With previous versions of the codec, we recommended that 1-pass CBR be used for HD content, since there was a problem with occasional dropped frames with 2-pass at high bit rates. This issue has been addressed in the v11 codec, and 2-pass VBR can now be used for HD content. This can result in big savings in file size.

2-Pass Bit Rate VBRThe unconstrained 2-pass bit rate VBR mode is just the same as constrained VBR, but without any peak constraint. This means that playability isn't predictable, and n most cases the constrained mode should be be used instead.

General Parameters
Data Rate
Probably the most critical parameter for any WMV file is its data rate. This determines how big the file is, and how much bandwidth a user would need to stream it. By default, Windows Media measures data rate in kilobits per second (Kbps). To figure out how big a file at a particular data rate is going to be, use this simple equation: the size in KB equals the data rate (in Kbps) divided by 8 times the duration in seconds. The "8" is in there as data rate is in kilobits per second, but file size is in kilobytes per second. I use "b" for bits and "B" for bytes as shorthand.

Note that Windows Media, like most streaming platforms, uses the correct base-10 metric values for K, M, and B, not the base-two derived values often but erroneously used for shorthand in computing.

To correctly predict the file size, note that you're calculating accuarate KB sizes, while most operating systems list file sizes in KiB/MiB/GiB by default. To get the real value, see the file's Properties and look at the value in bytes. For more information see this article.

Peak Buffer Size
The buffer-size parameter is available for all bit rate-limited modes. It specifies the duration (in seconds) of the window over which average (for CBR) or peak (for VBR) bit rate is calculated. Bigger buffers can provide more efficient encoding, but make hardware decode more complex and increase latency. For real-time streaming, the maximum startup and random access latency can go up by up to a second for each additional second of buffer.

Peak Bit Rate
Only used in bit rate VBR (peak), the peak bit rate value indicates the maximum bit rate during the peak. Higher values improve the quality of difficult sequences, but also increase the complexity of the decode. A simple way to determine appropriate bit rate is to encode in CBR with the same parameters, and find the highest data rate that will play back reliably. You can then use that as the peak bit rate.

Keyframe Interval
Keyframe interval determines the maximum time between keyframes. A keyframe (also called an I-Frame, for independent or intra frame) is a fully self-contained frame with no other frame based on it. These are the only frames that can be immediately jumped to in random access.

More frequent keyframes make random access, like scrubbing through a file or startup for a streaming file, faster. However, they also reduce efficiency, since a typical keyframe needs more bits to provide equivalent quality compared to normal frames.Note that the codec will insert additional keyframes as needed throughout the file, at points where the video changes dramatically.

Quality
The quality parameter used in the CBR and 1-pass (quality) VBR modes controls the target quality for the video. In quality VBR, it simply controls the quality of each frame, and hence how many bits it gets relative to its difficulty—higher values look better, but take a lot more bits.

In CBR, it controls emphasis on spatial versus temporal quality, essentially setting a minimum bar on frame quality. Lower values let the quality of video frames drop as low as needed in order to hit the target data rate without dropping frames. Higher values set a higher minimum frame quality, and the codec will drop frames on encoding in order to ensure the target bit rate and quality targets are maintained.

Using low quality settings can result in poorer video quality, even when the video is in no danger of dropping frames. This is because the codec doesn't always perfectly adapt to future changes in the video. In general, for most content you want to find the highest value that doesn't drop frames. The v11 codecs, especially if you're using the new registry key settings, can be a lot more efficient than previous iterations, so you can use a higher quality value with the same source and settings than before. I think 75Kbps is a good starting value for most web video now. If you're using Windows Media Encoder, it'll report after the encode if there were any dropped frames, a handy way of seeing if you're using too high a setting. WME also provides reasonable defaults to start with.

Streaming Covers
Free
for qualified subscribers
Subscribe Now Current Issue Past Issues