8

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)?

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
tulipe
  • 676
  • 2
  • 8
  • 22
  • 1
    Welcome to StackOverflow. Media Foundation is great to work with, and performs very well. If your requirements include real-time, you will be best served by writing your own C++/CLI wrapper to orchestrate the overall process. I assume you mean bit rate (as opposed to baud rate). Are you wanting to capture a webcam stream? Are you encoding /decoding to possibly more than one media type? Is audio included? – Jeff Feb 02 '15 at 20:30
  • @Jeff Thanks for your answer yes I want to capture a webcam stream and while I am capturing it I encode frames each time cycle and append it to the desk,I can put in one container not many(may be byte stream also without container).I need video only I am not caring about audio at all – tulipe Feb 04 '15 at 06:18
  • 2
    I'm no media foundation expert but I have found the best way to interact between it an C# is to use Managed C++. I've managed to capture live video from Media Foundation to my C# WPF application. The main C++ class is here but be warned again that I'm no expert on MF http://sipsorcery.codeplex.com/SourceControl/latest#sipsorcery-media/SIPSorcery.Media/MFVideoSampler.cpp. – sipsorcery Feb 06 '15 at 10:56

1 Answers1

4

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

  • 3
    Where do you find the Media Foundation .NET C# wrapper? Is there an official release or are you referring to the "snarfle" project at source forge? – Mark Lauter Jan 16 '19 at 03:38