So what’s the difference between a filter and a codec?

These are two words that are probably used more than most on the Movie Maker newsgroups and sometimes you’ll notice the words are used synonymously. So is a filter the same as a codec or not? Well in actual fact they’re not exactly the same as I’ll try to describe below.


First a little background. What is a codec anyway? A codec is a piece of code that is responsible for encoding and decoding a piece of video or audio. So why would you want to encode a piece of video? Well the process of encoding, also compresses the video data. The thing with video is that it’s big. A typical video file on the PC has a resolution of 720x480 pixels. If you use 24 bits for each pixel color, then that’s 3 bytes per pixel and that adds up to almost a megabyte for one frame. If you have 30 frames per second a quick calculation will show that an hour of video occupies over 100 gigabytes. Even with the size of today’s hard drives that’s still a lot of data. (Note that there are various formats that are used to store color information, 24 bit RGB is just one that maps well for a computer). No matter which color format you choose, uncompressed video is still large. Therefore, instead of storing the data uncompressed, codecs are used to encode the data into a more reasonable size. There are many different codecs used in the world of video, WMV, MPEG-2, DV are just a few examples.


Anyway back on to the difference between a filter and a codec. Perhaps this will be a little clearer if we look at what happens when you try to play back a video file using DirectShow. DirectShow comes with a nifty little utility called GraphEdit that can be used to create, view, and play DirectShow graphs. Here’s a GraphEdit screen showing a DirectShow graph that has been created for playing back a particular DV-AVI file that I have on my system.





Each one of those blue boxes is a DirectShow filter. It starts on the left with a file source filter which is responsible for reading the actual bytes from the AVI file on the disk and passing them on to the next filter. The AVI Splitter filter then extracts the actual DV data from the AVI data and sends those bits along. The DV data contains the video and the audio interleaved together so the DV Splitter takes that data and separates the video and the audio data. The audio data is sent to the Default DirectSound Device filter which will send the audio to the sound card so you can hear it. The video data from the DV file is sent to the DV Video Decoder. As you’ve probably guessed by now the DV Video Decoder is a DirectShow filter that internally uses the DV codec to decode the DV data to get the uncompressed video data. This video data is then sent to the Video Renderer which will display the video on your screen.


So you can see that in the case of the DV Video Decoder that particular filter will sometimes be referred to as a codec just for quickness. However there are many other DirectShow filters that aren’t associated with a codec. This is why the new Compatibility tab in MovieMaker 2.1 talks about filters and not codecs as when a filter causes a problem with MovieMaker it is not necessarily a codec filter.