Use specific codec or ffdshow folder with DirectShowLib?

1.5k views Asked by At

I am using DirectShowLib in a C# application to allow video playback. Unfortunately, not all systems provide a decent video codec so I opted to install FFDShow as part of my installation. Unfortunately this doesn't seem to work for certain users since they either already have several video codec packs installed or are using old versions. Or, for example, Windows 7 does no longer require it.

When I played with libvlc some time ago they allowed me to specify the plugin path with all the supported video codecs, but unfortunately I cannot seem to find something similar with DirectShowLib.

Is there a way to either pack the required codec libraries as part of my application and point to that folder, or install FFDShow into a specific folder and reference that one?

1

There are 1 answers

0
David Paxson On BEST ANSWER

One possible approach you could take is to use registration free COM. You would sepcify in your manifest file that you are using a particular group of subcomponents (such as a subdirectory containing FFDShow components). You would also need to create a manifest for the DLL's in that subdirectory. The main gotcha is you have to instantiate your objects from C# similar to this:

DsGuid MicrosoftDemux = new DsGuid("{AFB6C280-2C41-11D3-8A60-0000F81E0E4A}");
var demux = (IBaseFilter)Activator.CreateInstance(Type.GetTypeFromCLSID(MicrosoftDemux));

Once you have the filter, you can then add it to your graph, cast to other interfaces, or whatever else you want to do.

To help create the manifest file for FFDShow components, you can use regsvr42 (described in this answer: Generate Manifest Files for Registration Free COM

I have successfully used this to use DirectShow filters without registering them. One thing to keep in mind is the COM files must be in the same directory as your application or a subdirectory. Having them in a neighboring directory will not work.