Click here to Skip to main content
Email Password   helpLost your password?

Sample Image

Introduction

Besides the Microsoft SDK documentation, the information needed to program DirectShow applications is limited. This web site supplies many of the most useful references for programming these applications in C#. In order to continue this tradition, I have created a help file (.chm) that contains ten tutorials that illustrate how DirectShow applications can be written in C#.

Background

In general, the resources for programming DirectShow applications are scarce. In the past few months, I have written many tutorials that illustrate how to perform many common tasks in DirectShow with C#. I have put all these tutorials in one .chm file and provided access to all the source code samples from it. Moreover, the CodeProject web site has a nice messaging system to support the users of the code provided on this site, which should make these tutorials even more useful.

Using the code

I have provided a Visual Studio project file for each tutorial, and I have also included a .cmd file to compile it from the command line. Sometimes, these .cmd files contain references that need to be changed to reflect your local settings. I have mentioned these in the tutorial "readme.txt" file. Some tutorials will only run on 32-bit machines.

Points of Interest

The tutorials show how a simple multimedia player, a simple capture, a jukebox, and an append utility application can be written. Moreover, we have implemented versions of the Picture-In-a-Picture, custom allocator/presenter, custom image compositor samples from the DirectShow SDK in C#. And we have implemented the functionality of the EzRbg24 filter in C#.

Limitations and known issues

As mentioned previously, some samples will only work correctly on 32-bit machines. Moreover, I don't claim that these are optimal solutions. Many years ago, when I was teaching a VC++/MFC class, one student asked me where I was taking the code that I was using during the lectures. I replied that I had two directories with more than eighty samples in each of them, that I had written over a while. I was just picking some of these and brushed them up a little before presenting them and asking the students to modify or extend them (during the lectures or for assignments). I give these samples in the same spirit; but I'm still a long way from having more than hundred and sixty samples to chose from ;-)

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralAnti-flicker problem
QuyLV
22:37 19 Feb '09  
I have problem when programming camera with Directshow, it is setting local line power frequency. I still don't know how to set it 50Hz or 60Hz. Please help me.
GeneralSave PIP as wmv file
rama srinu
6:09 23 Jan '09  
Hi,

I have seen PIP sample application. It is working fine. I want to save the result of PIP in wmv format.
I appreciate your concern about my requirement.

Thanks,
Ram
GeneralMultiple Sample Grabber Objects
kazim bhai
6:42 11 Jun '08  
I am using Buffer CB function using two sample Grabber objects,
How may I know the buffer called is video or Audio as I want to process both of them while redering one file with both audio and Video.

Thanks in Advance

It is Kazim

GeneralRe: Multiple Sample Grabber Objects
daniel049
12:18 12 Jun '08  
Why aren't you using the SampleCB method instead? Then you can call GetMediaType to answer your question.

If it is not available in the DirectShow.Net library, you'll find how to use it in one of my blog entry.

http://www.informikon.com/blog/using-isamplegrabbercb--samplecb-in-c.html
Generalcannot display this HTML help file
HooNose_JJP
3:18 11 Jun '08  
If I open the chm, I receive the following error message:

"This program cannot display the webpage"

Anyone else with this problem?
GeneralRe: cannot display this HTML help file
HooNose_JJP
3:30 11 Jun '08  
Ok, solution found on this page: http://grounding.co.za/blogs/brett/archive/2007/10/10/fixing-quot-this-program-cannot-display-the-webpage-quot-error-for-chm-files.aspx[^]

.chm Files do not like the # ? & and + characters in the pathname.

I renamed the C# folder to CSharp, i.e. C:\Demos\CSharp\XMLDoc and it worked.
GeneralRe: cannot display this HTML help file
daniel049
3:59 11 Jun '08  
I answered this question, too, in my reply to the message "Can't read help file" in this forum.

-daniel
GeneralGreately in need of help
babu74
2:49 3 Jun '08  
I am not able to download the help chm file for directShow from this site could you send me the same at babu_74@rediffmail.com
General.net Compact Framework
s4souhail
9:43 3 Aug '07  
Hi

Would this work with compact framework? i am planning to use these directshow libraries on a windows embedded system. unfortunately all the code available out there is using c++

Souhail
GeneralRe: .net Compact Framework
daniel049
8:30 4 Aug '07  
I haven't tried it but it doesn't look promising (the following is taken from MSDN):

"COM Interoperability (COM Interop). This is used to interact with COM objects. Unfortunately, this is not available with the .NET Compact Framework. This feature is memory and processor intensive that defeats the purpose of the .NET Compact Framework."

Maybe others know more about this.

-daniel
GeneralJukebox: Step Forward works, but Step Backward has problems
stringtheory_x
20:22 5 Jul '07  
Daniel,

Your CSJukebox program has a 'Step Forward' button that works well.
When a Step Backward button is added, things start to go wrong:
The graph does step backward, but it goes out of pause into play.
Any idea why this happens?

GeneralRe: Jukebox: Step Forward works, but Step Backward has problems
daniel049
7:19 9 Jul '07  
Since I don't have your code, I can't say for sure, but have you tried to add an extra mediaCtrl.Pause() after the call to frameStep.Step? It might do the trick.

-daniel


QuestionHow to capture single frame
aishar
5:35 22 Jun '07  
I use many projectsd here in codeproject as dxsnapshot and others it give many errors in Grab single frame did u have any idea how to do that
GeneralAccess to Running Object Table?
stringtheory_x
0:35 31 May '07  
To connect to a 'remote app', GraphEdt requires an entry in the Running Object Table:

http://msdn2.microsoft.com/en-us/library/ms787252.aspx[^]

Do you have an easy method for doing this within your C# code?
It would be great to monitor the filterGraph.

GeneralRe: Access to Running Object Table?
daniel049
3:57 31 May '07  
DsROTEntry is defined in the lib at directshownet.sourceforge.net, you can use it as in:

DsROTEntry rot = new DsROTEntry(gb);

-daniel

QuestionProblem with your tutorial.. please help...
angeldoescry
6:34 9 May '07  
Hello,
Please can you help me..
I am going through your tutorial (really interesting!) (I need to access my camera)
In you're Tutorial2: yet another capture sample in c#

I have a few qestions :
1)

I am having this problem while compiling when I am compiling the idl file with midl :

Processing .\cap.idl
Processing C:\DXSDK\Include\DShowIDL\devenum.idl
Processing C:\Include\oaidl.idl
Processing C:\Include\objidl.idl
Processing C:\Include\unknwn.idl
Processing C:\Include\wtypes.idl
Processing C:\Include\basetsd.h
Processing C:\Include\guiddef.h
Processing C:\DXSDK\Include\DShowIDL\axcore.idl
Processing C:\DXSDK\Include\DShowIDL\axextend.idl
Processing C:\Include\ocidl.idl
Processing C:\Include\oleidl.idl
Processing C:\Include\servprov.idl
Processing C:\Include\urlmon.idl
Processing C:\Include\msxml.idl
Processing C:\DXSDK\Include\DShowIDL\control.odl
Processing C:\Include\oaidl.acf
Processing C:\Include\ocidl.acf
midl\oleaut32.dll : error MIDL2020 : error generating type library : LayOut failed : IVideoWindow

Why it doesn't recognize IVideoWindow?

2) My other question is about your .idl file :
what's that?
How do you know you have to add that and where does it come from?
[
uuid(2F5957F4-78A8-4101-B3B4-A30BFC5AD628),
helpstring("Capture type library")
]

3)
I am not a specialist of DirectShow... so how do you know you have to add and what's the signification:

//CLSID_FilterGraph (take from uuids.h DirectX include)
Guid FgGuid = new Guid( "e436ebb3-524f-11ce-9f53-0020af0ba770" );
//CLSID_CaptureGraphBuilder2 (take from uuids.h DirectX include)
Guid CgGuid = new Guid( "BF87B6E1-8C27-11d0-B3F0-00AA003761C5" );
//CLSID_SystemDeviceEnum
Guid DevEnumGuid = new Guid( "62BE5D10-60EB-11d0-BD3B-00A0C911CE86" );
//CLSID_VideoInputDeviceCategory
Guid VidCapGuid = new Guid( "860BB310-5D01-11d0-BD3B-00A0C911CE86" );
// taken from strmif.h
Guid IID_IBaseFilter = new Guid( "56a86895-0ad4-11ce-b03a-0020af0ba770" );
// needed for calls to RenderStream
Guid PIN_CATEGORY_PREVIEW = new Guid( "fb6c4282-0353-11d1-905f-0000c0cc16ba" );
// needed for calls to RenderStream
Guid MEDIATYPE_Video = new Guid( "73646976-0000-0010-8000-00AA00389B71" );

const int WM_GRAPHNOTIFY = 0x00008001;
const int WS_CHILD = 0x40000000;
const int WS_CLIPCHILDREN = 0x02000000;
const int WS_CLIPSIBLINGS = 0x04000000;


Thanks a lot for your reply...Please help me...


AnswerRe: Problem with your tutorial.. please help...
daniel049
15:06 10 May '07  
Hi,

Your questions relate to COM programming and since DS is based on COM, it is not surprising. You should look at a good COM reference but if you want to learn as little as needed to program DS, you might want to look at directshownet.sourceforge.net for a complete wrapper of DS that can be used from .Net and you can avoid doing the stuff above since they have already done it for you.

I didn't use it much when I wrote these tutorials because it was being developed at the same time as I was writing them. But now, you can avoid most of this tedious stuff by using their library.

-daniel
Generalmu-LAW to MP3
Vince Zhou
14:47 2 May '07  
I want to convert mu-LAW audio files to MP3.
Do you have a sample on how to do this in DirectShow?

thanks,

GeneralRe: mu-LAW to MP3
daniel049
9:21 5 May '07  
Hi,

I'm not familiar with the details of mu-Law format and I don't have a sample that you might find useful.

To encode to mp3, you'll need a third-party ds filter (eg lame). You'll also need to provide your own filter to decode your mu-law data.

Maybe this can get you started:
http://www.codeproject.com/audio/dshowencoder.asp[^]

-daniel
GeneralVMR9 and DX9 surface input
wingnutman1
3:47 18 Apr '07  
Hi,

Thanks for the great work with the help file - it's invaluable.

I have been looking at this for a number of days - i want to input a DX9 surface to the input pin of a VMR9 filter. The surface is being rendered separately and I need to overlay this on a video stream.

Any ideas if this can be done?

Thanks,


John
GeneralRe: VMR9 and DX9 surface input
daniel049
10:43 20 Apr '07  
If you want decent performance, your DX9 surface has to use main memory otherwise reading from the surface will kill you. A custom A/P should do the job.

You might want to look at the vmr9allocator2 sample from directshownet.sourceforge.net

-daniel
GeneralGreat article !!... I need some help regarding video streaming....
sidsidz
22:06 31 Mar '07  
How can I give a byte array as input to a filter graph ?

I am getting an MPEG video stream which I am saving in a byte array. I have to decode this stream. After some research, I have decided to do this in DirectShow. I am working in C#. In this regard ur tutorials were a great, great help !!!!

Now the problem:
How do I provide this byte array stream to the filter graph ?
Should I use the Source Filter?
Or will I have to obtain that byte array as an object in COM?

I am using DirectShow for the first time. I would be really grateful if I could get a reply soon as I am working on a project and time is short. Tell me if I am not clear in my description of my problem. I'll try to explain more.


__________________________________________
Trying to make sense of it all ...
QuestionBuilding a DirectShow application
Maynka
2:59 27 Mar '07  
Hi,
I have Visual Studio installed in my system.How can i build the DirectShow application using that.Please point me to any sources on net which have DirectShow applications and the method of building the same.

Regards,
Mayank
AnswerRe: Building a DirectShow application
daniel049
4:37 29 Mar '07  
A good starting point is: http://tmhare.mvps.org/faqs.htm[^]

-daniel
QuestionCan't find the resource file
hdtntran
14:15 18 Jan '07  
I am using VS 2003 to compile the code but got error message said can't find the Form1.resx file. Where can I got these file for all the project? It doesn't include in your zip files.

thank youConfused


Last Updated 6 Oct 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010