Finding The Right Size, Codec and Compression For Video in WPF (Avalon)

When using video in Avalon, you are free to use any codec supported by Windows Media Player.  This is liberating, in that you have a range of options as far as codec and compression, but the fact that you have a choice mean you have to make a choice.  Figuring out what codec and how much compression turns out to be a complex intersection of variables and decision points.  

Let's say you have some raw, uncompressed .avi footage that is 500 megabytes.  Such a file has a price in terms of size.  Not only does its size potentially impact download size of the application, but it also has a cost in terms of disk i/o.  Compressing the file has advantages as far as size, but it has a cost in terms of cpu cost for decompressing the codec at runtime.  The more you compress, the smaller the file but higher the cost of decompressing.   The less you compress, the decompressing is faster, but disk i/o is higher.  Finding the perfect balance can be tricky.

There is also a quality consideration here -- are you showing the file full screen or in a relatively small viewbox?  Are doing something intensive with the video like animating it or mapping it to a 3D mesh?  Lastly, you need to take into account the hardware expectations you have among the users of the application.  Can you require a certain level of hardware or not?  All of these considerations go into deciding which codec to use (.wmv? .divx? stay with .avi?) and how much to compress the file.

Having played with this interplay of variables on a series of WPF (Avalon) applications built for the PDC, I unfortunately can't give any black and white recommendations.  My advice is to experiment, based on your requirements and scenarios.  Ideally, you should have the raw uncompressed video so that you can experiment with different kinds of codecs and different extremes of compression.  An essential tool when doing this experimentaiton is the Windows Media Encoder 9 Series, a free tool.