Media Foundation with C#

tulipe picture tulipe · Feb 1, 2015 · Viewed 9.1k times · Source

Media foundation is the recommended technology by Microsoft and it has really supported it by a lot of samples and explanation but all are with the native code

I found a wrapper in sourceforge make me able to use Media Foundation with C# but while I am reading people talk about not every thing can be done by the managed code

I have some tasks to do with MF:

  1. Capture alive video
  2. change resolution and baud rate
  3. Encode video
  4. decode video

Can I use .net in these tasks or I have to use the native code?Is there samples help (please don't mention msdn one from them)?

Answer

Brentley_11 picture Brentley_11 · Aug 18, 2017

The Media Foundation .NET C# wrapper can work well for all those tasks you mentioned. I've used it personally to implement the capture, resizing, and encoding, and I imagine decoding shouldn't be too hard either.

The project does have some examples you can download but I find them rather lacking. The wrapper is so close to the C++ implementation that it's not too hard to use C++ examples and just port the logic to C#. I used the following as a reference and found it to be very valuable: https://github.com/sipsorcery/mediafoundationsamples