Click here to Skip to main content
Click here to Skip to main content

Tagged as

DirectShow Filters (For Beginners)

, 23 Sep 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
DirectShow filters are described in an easy to understand way.


DirectShow filters are COM components which are connected together to build a filter graph. A filter graph is a complete mechanism (different filters connected together) which is needed to run a media file. Normally, a filter is capable of doing a single work, meaning a filter is an entity which is fully capable of processing media file data. Therefore, if you want to process the media file data, the most powerful technique is to build your own filter which can perform the required job.

Modular Design

Another benefit of building your own filter is that, internally, DirectShow has a modular design, meaning it is made up of small components working together to do a job. This design frees the developer from many worries. If you build your own filter (according to specifications), you don't need to worry about the other parts of the filter graph. If your filter works OK, then every thing will be OK. Otherwise, you are confirmed that your own filter is malfunctioning and not any other filter, because the other filters are already tested by the respective developers.

Data Flow in the Filter Graph

Data flows in the filter graph from one filter to another. The filter which gives the data is called the upstream filter and the filter which takes that data is called a downstream filter. The data flows from upstream filter to downstream filter, and this is called upstream filter push data (see Transport for push and pull).

Filter Types

Normally, filters are divided in three categories:

  1. Source filters
  2. Transform filters
  3. Renderer filters

Let us see them briefly.

Source Filters

These are the source of data that flow inside the filter graph. They provide data to the downstream filters (or downstream filter snatches data from the source filter, see Transport below). They come in three categories: capture source filters, file source filters, creator source filters. Capture source filters are those that get data form capture devices, such as camcorders or web cams. File source filters are those that get data from stored files. And the last, creator source filters are the type of filters that create data themselves to be flown in the filter graph.

Transform Filters

This is the category of filters which is used and created most. Any filter other then the source filter and renderer filter (see below) is called a transform filter. They get data from a source filter or any other filter upstream, and do the custom operation over data and pushes that data downstream. The custom operation here means the work they are made for; some parse data, others decode data, or any operation you want to be done over data.

Renderer Filters

The data in the filter graph flows from the source filter through the transform filters towards the renderer filter. This is the filter which sits at the end of the filter graph. The examples are filters which show video over screen, or write data to a file.

Connecting Filters

A filter is a COM component which has input and output pins. These are also COM components. All data travels through these pins. The output pin of the upstream filter is connected to the input pin of the downstream filter.

Connection Requirements

It is not so easy to connect any two filter pins. There must be a negotiation of some requirements. The actual negotiation work is done by the pins, which must be met before a connection takes place.

What are these requirements and why must they be met. Let us see:

The requirements are:

  1. Media type(s)
  2. Transport
  3. Allocators

Let us briefly see what they are.

Media Types

When two pins connect, they must agree on the format of the data which will be passed so that when actual data flow begins, the downstream filter can understand the format of data that the upstream filter is giving it.


The two also must agree on the protocol or the mechanism which will be used to exchange data. The most common transport is local memory. There are two mechanisms for local memory transport: push and pull. In the push model, data flows from the upstream filter to the downstream filter. And, in the pull model, the downstream filter pulls the data from the upstream filter. The pull model is only used in file source filters the filter read data from the file(s). All others use the push model.


Allocators are also COM components which are responsible for managing the buffers which are used for data exchange.

More Info

You can visit my site on ongoing work in DirectShow.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

tanvon malik

Pakistan Pakistan
tanvon malik ( real name Tanveer Ahmad )I am a CNC Programmer, cnc setter, cnc operator. want to know about me visit my blog.
CNC Programming Blog

Reach Me
cnc blog | facebook | twitter | linkedin | flickr | google+

I been in Switzerland MAG former +FMS+ for CNC training.

Most interesting technologies I like COM MFC DirectShow such as filter development. I am from Pakistan.
Have worked on projects mostly related video capturing, video data processing and real time object tracking on videos. For these I have worked on projects which use "Open CV Library". Which is mostly used for capturing data and its processing.

my vc++ blog tanvon++
my blog about DirectShow in my national language URDU
and below is the place where we discuss DirectShow and VC++
Follow on   Twitter

Comments and Discussions

GeneralMy vote of 4 PinmemberBrendan Segraves24-Jan-13 6:14 
Questionselect output device with directshow Pinmemberkinani12-Aug-11 2:51 
GeneralMy vote of 3 PinmemberMostafaz23-Nov-10 0:20 
GeneralMy vote of 1 PinmemberBalkrishna Talele9-Oct-09 0:29 
GeneralLIVEVIDEO ROTATION OR FLIP H/V FILTER Pinmembergiuegiu6-Jul-09 22:12 
GeneralRe: LIVEVIDEO ROTATION OR FLIP H/V FILTER PinmemberAric Green13-Feb-10 21:05 
GeneralPush audio / video file to Server that uses Windows Media Services(WMS) PinmemberHarshil_Gunchala14-Feb-09 2:57 
GeneralFME PinmemberPaul the Great18-Jan-09 2:28 
Generaldirect show PinmemberMember 242714927-Dec-07 20:04 
GeneralRe: direct show PinmemberAric Green13-Feb-10 21:09 
Questionhow to design parser filters. Pinmemberamiya das27-Sep-07 4:17 
Questionhoe to create a parser filter. Pinmemberamiya das27-Sep-07 1:17 
AnswerRe: hoe to create a parser filter. Pinmembertanvon malik27-Sep-07 4:02 
GeneralMy DirectShow sample filters ... PinmemberDaniel Strigl24-Sep-07 4:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 24 Sep 2007
Article Copyright 2007 by tanvon malik
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid