Media Foundation .Net

Purpose: The goal of this project is to allow programmers who create managed applications to use the interfaces in Vista's/Windows 7 Media Foundation. If you are not a programmer, or are not running on (at least) Vista, there is nothing in this project that you are going to find useful.

If you have questions, comments, or just want to offer encouragement, post a message to this project's forum at

Downloads including samples, library, and the complete source code are at

Related libraries can be found at:

October 4, 2016

Project Status

Version 3.1 is now available to download in the files area. This release has moved all remaining testable interfaces out of the untested section.

Also, a series of extensions to Media Foundation interfaces and externs has been added. See readme.mfext.html for more information.

At this point, no further work is planned for this library (with the possible exception of bug fixes).

July 4, 2015

Project Status

Version 3.0 is now available to download in the files area. This release moves the 28 testable W8.0 interfaces out of the untested section. The next release (3.1) will include the Windows 8.1 interfaces.

Also in v3.0, the licensing has been expanded to include either LGPL or BSD.

New samples have been added showing how to write Media Foundation Transforms (MFTs), along with templates to make them easier to write.

April 19, 2015

Project Status

Version 2.2 is now available to download in the files area. In addition to upgrading to framework v4.0.3, this release moves an additional 20 interfaces out of the untested section. These interfaces are the last of the <= Windows 7 interfaces and externs that can be tested. The next release (3.0) will begin targeting the Windows 8 interfaces.

v2.2 also includes a new feature: Support for getting F1 help on MFNet interfaces thru MSDN. To use this feature with VS2012 and up, run docs\insthelp.cmd.

April 7, 2015

Project Status

Eric and I are almost done making a second pass thru some of the interfaces I had previously skipped. This should get us another ~20 interfaces for v2.2. That's probably the last of the pre-Windows 8 interfaces that can be done (unless MS is willing to step up and provide more info about how MediaFoundation works).  As mentioned back in March, we are also moving from framework 3.5 to 4.0.3.  While moving to 3.5 was a big step forward from 2.0, 3.5 was still pretty old (2007).

There is a new feature that I'm planning to include in v2.2 as well: Getting MSDN help for MFNet interfaces inside Visual Studio. Currently if you press F1 on a MediaFoundation interface (like IMFAttributes) or interface method (such as IMFAttributes.GetItem), you are taken to MSDN, which informs you that MSDN has no help to offer for MediaFoundation.IMFAttributes.GetItem. Since that namespace is unique(-ish) to this project and is not defined by MS, it is no surprise that MSDN has no help to offer. In fact, it becomes kind of irritating that it even tries.

However, MS Help (which is what Visual Studio uses) has a way to redirect help for certain objects to an alternate website via registery keys. I have created a batch file to add the necessary keys to send the request to, and I have updated MFNet.SourceForge.Net to process and redirect the requests to MSDN.  While this won't work for everything, it does work for most interfaces, interface methods, structs, enums, and the methods on MFExtern.

One of the components of this feature is a PHP script (to redirect the url). I am not an expert at php, so while the script works, it could probably work better (smaller, faster, safer, etc). If you are a php expert and have a minute to look this over, the file is checked in to CVS at The batch file to add the registry keys is at, and is expected to be included in the upcoming v2.2 release of the library.

Looking ahead, the next set of interfaces are the ones from Windows 8.  We'll probably call that v3.0.  There are 46 Windows 8 interfaces.  That's a lot.  Instead of trying to do them all in one release, we may need to split this up some.  Unless we can get some people to help.  If you are available to write some c# test code using MediaFoundation in Windows 8, let me know.

March 15, 2015

Project Status

Thanks to the work by Eric, I'm pleased to announce the release of MFNet v2.1. This release contains 28 more tested interfaces, and 105 more tested externs along with 3 new samples. You can find the new zip files for the library and the samples in the Files area. Also of note: The library has moved from framework version 2.0 to 3.5.

We are looking at what to work on next.  Currently defined in the library (but untested) are:

Of the skipped, some are because I couldn't figure out how to test them (like the IMFDRMNetHelper & IMFSSLCertificateManager).  Some are broken (like IMFSimpleAudioVolume).  Some are described as "Applications do not use or implement this interface."  But there may be some useful ones here too.

If we don't find anything interesting among the skipped, we might jump straight to the W8 interfaces.  If you have some specific interfaces you'd like to see (especially if you are willing to help test them), post a message to this project's forum at

I'm also considering moving to Framework v4.  While moving from 2.0 to 3.5 was a big step forward, even 3.5 is getting kinda old.  Feel free to share your thoughts on the forum.

FYI: As of today, we are just short of 20,000 downloads of the MFNet library.

November 22, 2012

Project Status

I said back in March on the project's home page that I was seeking helpers for work on v2.1. While I heard back from a few people, most disappeared after just 1-2 emails. The amount of actual work provided by volunteers was disappointingly limited.

I found this particularly frustrating, since there really wasn't that much work to be done and it doesn't require particularly advanced programmers to do it. Surely somewhere among the nearly 4,000 downloads since then, there must be at least some folks willing to donate some time.

Still, I myself use a number of OS projects without volunteering to help on them, so I can't really fault people for not stepping up.

But as a result, I am not (currently) planning on doing any more development work on MF.Net.

I will continue to respond to posts in the forum that strike me as interesting, and if people report bugs, I may look at them too. We'll see.

Will I ever do more work on this project? Maybe. But without at least one (and preferably more) committed volunteers to work on it with me, probably not.

As of this posting, all the work I have done post v2.0 is checked into the project's CVS under src and samples. I wanted to make sure none of it would be lost. This work includes a few updates beyond what is in the released downloads. In particular:

I hope that having a centralized place that contains all the classes, structures, enums, and interfaces for Media Foundation is something you are finding useful, and that the samples give you some idea of how to get started with MF.Net. Remember that you have the complete source code to the project (all c#) and in a pinch can resolve any outstanding problems yourself.

March 9, 2012

Looking for helpers for v2.1

If you are interested in offering to help with the release of v2.1, see the thread at If you don't have access to the Developers forum, send me an email at

March 7, 2012

V2.0 finished

V2.0 has been released and is now ready for download in the Files area. Both the library and the samples have been updated, so make sure you grab the 2.0 version of both.

March 1, 2012

V2.0 nearing completion

Yes, it has been a while, but I've dusted off the files and am working to release v2.0. I have trimmed down the list of tasks I am trying to achieve for this release by removing #5 (see list below). v2.1 will target these interfaces for testing.

If you are available to help review the beta, check out the thread in the forum ( But hurry.  The plan is to ship this on March 7th.

August 22, 2009

V2.0 is in progress

There are several tasks I'm trying to accomplish for v2.0:

As of today, the first two items on the list are done and checked in. The samples are probably next on the todo list. If you have any preferences about which interfaces need to go on the list to be tested for v2.0, feel free to share you thoughts in the forum at  If you are willing to help create the tests for your chosen interface, that's going to push it to the top of the list.

June 10, 2009

v1.1 of the library released!

In v1.1 I have tested all the Vista MF interfaces I intend to test. Along with the updated library, I have also released an updated samples project which includes my EVRPresenter sample. You can download both of them in the Downloads area.

v2.0 (if and when there is such a thing), will include definitions of the new W7 interfaces. MF only has 20 new interfaces in W7. How hard can it be? v2.0 will probably also use HRESULTS instead of exceptions (see discussion below).


May 21, 2009

I now have a working customer presenter for the EVR written in c#. Woo hoo!

This was a huge project and there was some finicky work required. However, the question now is, what do I do with it? It doesn't really fit as a sample for this project, since it uses DirectShow. And it doesn't fit there cuz it uses MF. It's a little small for its own project. And really, it's pretty complex to even be called a sample.

Suggestions anyone?

May 20, 2009

Thank you to all the people who responded to the "Do you want another release?" thread. It always feels good to know people are using what I'm writing.

Since there does appear to be some interest, I've decided to do at least one more release, and possibly two.

In the first release, I am going to attack the remaining Vista interfaces. I have picked out the ones I intend to do and have already started creating tests for them. This includes the last of the easy interfaces, and all of the remaining ones I find to be interesting. If there is some particular interface you need, this would be the time to mention it. Check out your docs\Interfaces.txt for the status of the existing interfaces. If you need an interface enough to request it, be prepared to help create the test for it.

The second release will contain the W7 interfaces. Looks like they added about 20 interfaces. I don't have W7 installed, so I don't yet have a way to write any tests for the new interfaces, but hopefully soon.

And while we are talking about an update to the library, a new question has arisen. There is a major difference between the way DSNet returns errors (uses an HRESULT), and the way MFNet returns errors (throws exceptions). However, I'm considering changing MF to be like DS.

There are several reasons that throwing exceptions are better than returning HRESULTS:

There are also reasons that using HRESULTS are better than exceptions:

As you can see, the benefits for exceptions are mostly cosmetic. The functional items for HRESULTS are rather compelling.

I hate to do it. I *like* the exception model, and I really appreciate the cleaner code that results. But I'm definitely leaning that way. I just created a project where the slow performance of many exceptions being thrown was a problem. So unless someone can throw some weight on the "exceptions" side of the scale, that's probably what I'll do.

If you have any feedback on these subjects, feel free to start a thread over in the forum.

And if I'm going to do this and shatter backward compatibility, it makes sense to do it now, before the big W7 rush of downloads (he dreams).

March 21, 2009

So, here we are a year and a half later. I still haven't really heard any feedback from anyone. To my surprise, there have been over 1,000 downloads of the library. On the other hand, there have been less than 10 threads in the forum over the entire lifetime of the project. I'm interpreting that to mean that while people are grabbing a copy of the library in case they ever need it, very few people are actually using it.

Looking forward, Microsoft has added a bunch of new interfaces to Windows 7 ( They are designed to make MF much easier to use, as well as expanding the functionality. Obviously these features will only work in W7 (and beyond).

So, the question is, does anyone think we need to add these definitions to this library? Or is there just not enough interest in using Media Foundation from c# to make it worth the effort?

Post your thoughts here:

September 23, 2007

Well, I'm a little late, but it's not my fault!  My (only) Vista box died on me.  Kinda hard to work on a project that only works on Vista if you don't have any working Vista computers.  I just got it back from HP on Friday.  I will say that it was a HUGE relief to go back to an operating system that doesn't fight you at every turn for a few days.  I may leave this Vista box on the shelf and just use my XP box again.  Except when I'm working on this project.

In any case, I've done what I intended to do for v1.0.  In fact, I've added even more samples than I intended, so make sure you download both the updated lib, and the updated samples.

I know this release isn't going to be perfect, but until I hear from others, I don't know what else to work on.  So, if you like it, hate it, or even if you just use it, drop a note over at the forum ( and let me know what you think.

Here is a list of interfaces that have been tested for v1.0

IEVRFilterConfig IMFClockStateSink IMFMediaType
IMF2DBuffer IMFCollection IMFMediaTypeHandler
IMFActivate IMFContentEnabler IMFPresentationClock
IMFASFContentInfo IMFContentProtectionManager IMFPresentationDescriptor
IMFASFIndexer IMFFinalizableMediaSink IMFPresentationTimeSource
IMFASFMutualExclusion IMFGetService IMFSample
IMFASFProfile IMFMediaBuffer IMFSequencerSource
IMFASFSplitter IMFMediaEvent IMFSourceResolver
IMFASFStreamConfig IMFMediaEventGenerator IMFStreamDescriptor
IMFASFStreamSelector IMFMediaEventQueue IMFStreamSink
IMFAsyncCallback IMFMediaSession IMFTopology
IMFAsyncResult IMFMediaSink IMFTopologyNode
IMFAttributes IMFMediaSource IMFTransform
IMFByteStream IMFMediaSourceTopologyProvider IMFVideoDisplayControl
IMFByteStreamHandler IMFMediaStream IMFVideoMediaType

These interfaces are defined in the library, but aren't yet tested.

IEVRTrustedVideoPlugin IMFOutputSchema IMFSimpleAudioVolume
IMFASFMultiplexer IMFOutputTrustAuthority IMFSourceOpenMonitor
IMFAudioPolicy IMFPMPClient IMFTimer
IMFAudioStreamVolume IMFPMPHost IMFTopoLoader
IMFByteStreamBuffering IMFPMPServer IMFTopologyNodeAttributeEditor
IMFDesiredSample IMFQualityAdvise IMFTopologyServiceLookup
IMFInputTrustAuthority IMFQualityManager IMFTopologyServiceLookupClient
IMFMediaSinkPreroll IMFRateControl IMFTrackedSample
IMFMediaSourcePresentationProvider IMFRateSupport IMFTrustedInput
IMFMetadata IMFRealTimeClient IMFTrustedOutput
IMFMetadataProvider IMFRemoteDesktopPlugin IMFVideoDeviceID
IMFNetCredential IMFRemoteProxy IMFVideoMixerBitmap
IMFNetCredentialCache IMFSAMIStyle IMFVideoMixerControl
IMFNetCredentialManager IMFSampleGrabberSinkCallback IMFVideoPositionMapper
IMFNetProxyLocator IMFSampleProtection IMFVideoPresenter
IMFNetProxyLocatorFactory IMFSaveJob IMFVideoProcessor
IMFNetSchemeHandlerConfig IMFSchemeHandler IMFVideoRenderer
IMFObjectReferenceStream IMFSecureChannel IMFVideoSampleAllocator
IMFOutputPolicy IMFShutdown IMFWorkQueueServices

September 1, 2007

I have just checked in the WavSink sample.  That's the last of the samples (yay).  I've made a number of changes to the library over time, so I'm going to need to re-run the test suite to make sure I haven't broken things that *used* to work.  Plan still looks like v1.0 in mid-September.

WavSink, like WavSource has run into an MF bug.  There are a couple of Microsoft's COM objects that don't correctly support QueryInterface.  Managed code *really* doesn't care for that.  So, there are a couple more interfaces in the Alt.cs file.  When MS releases fixes, hopefully these declarations won't be needed any more.  Using IntPtrs instead of the actual interfaces for these methods works, but eventually I'm sure this is going to be a problem for someone.

Found yet another interesting bug in the PropVariant class.  The problem came when a Blob was being sent to an implementation of IMFStreamSink.  The code worked correctly, but as the program was ending, the finalizer was called on the PropVariant.  This was a real problem since the PropVariant had already been freed by the routine that called me so the finalizer was crashing.  I had no business trying to free the thing, it didn't belong to me.  Tracking this down took time, but I think I've come up with an elegant solution.

August 21, 2007

I've taken a break from testing interfaces, and have been focusing on converting the MF samples to c#. MF comes with 8 samples and my plan is to convert 7 of them. The 8th (DXVA2_VideoProc) uses DirectX interfaces which are (way) beyond the scope of my efforts for this library. If someone who knows more about DirectDraw wants to step forward and help, that would be great. Failing that, this small corner of MF won't be accessible from managed code.

In the meantime, I have converted 6 of the 7 samples, and have started work on the 7th. Finishing this sample seems like a reasonable milestone, so that's probably the point at which I'll declare v1.0. I've made enough changes now that I want people who are downloading to get that it's probably time.  Look for v1.0 in mid-September.

I continue to make minor tweaks to the library. Found an interesting bug in my PropVariant class the other day. The class is declared using LayoutKind.Explicit, so I didn't realize that the VariantType field was overlapping the reserved1 field. Wasn't a problem until I ran into something that was using the reserved1 field. Changing the VariantType to a short (which is what it should have been in the first place) solved the problem.

August 03, 2007

I'm continuing to create tests for interfaces and I have made a number of changes to the existing code.  Oddly enough, some code that worked fine in 64bit (my main dev machine) didn't work in 32bit.  Required a bit of cleanup.

My original plan was to do a release with just a selection of interfaces.  However, I've revised that plan.  Now I'm going to see about testing all of them for release v1.0.  We'll see.

I've got a total of 4 samples working now:


If you are doing work and need some particular interfaces done sooner rather than later, or are looking for a release with the latest samples/fixes, drop me a note over in the forum and I'll see if I can find a clean stopping point.

July 18, 2007

I have been doing some more work on the library.  I now have one more sample (a c# version of MFT_GrayScale), a couple more tested interfaces, and a few fixes for the code that was released in the beta.  However, I'm holding off on doing another release until I hear back from people.  If you have a minute, please, scribble a few lines for this message thread ( and let me know what you think of this project.

An interesting note: I was never able to get the DirectShow base classes to work with c#.  However, it appears that one of the benefits of Media Foundation is that the re-design is more compatible with managed code (whether by design or just happenstance, I couldn't say).  I have now written two "filters" for MF in c#:  One a source filter, and one a transform filter.  While I haven't done any detailed performance comparisons, they seem to give comparable results to the c++ samples on which they are based.

July 14, 2007

Beta 1 is now ready.

I have created 2 zip files (one for samples, one for the library) and they are available in the Downloads section (see above).  I am now looking for people to read the docs, compile/run the samples, and let me know what they think. 

July 9, 2007

Much progress has been made.  I have changed all the interfaces to remove the PreserveSig attribute, and wrote tests for 33 of them. Next step is to create some documentation.

Sometime in the next few days, I could use some help making sure v1 of the product is ready.  If you are interested, drop me a line at

July 1, 2007

Right now, this project is still in its early stages. At this point it is just barely past the "proof of concept" state.

Included in the project is the code for the library, and two samples that use it.

The library has the definitions for all of the Media Foundation interfaces, plus all the structures and enums that they use (at least I *think* it does). It also contains definitions for a few helper classes (MFError, COMBase).

The two samples are translations of the c++ MF samples BasicPlayer and WavSource. Both samples run (at least on my machine). As of today, these samples don't even have readmes. To find out what they do, read the c++ docs for the related sample. To get WavSource to run, you'll also need to know how to use regasm.

I am still planning on large-scale changes to the library. So, while you are welcome to download and study this code, I wouldn't recommend doing any significant development based on it just yet.

Get Media Foundation .NET at Fast, secure and Free Open Source software downloads