Search code examples
ffmpegdirectshow

How would I go about making a screen recorder?


I understand mp4 files, AVI files, the list goes on. I also understand encoding and compression and bitrate. I wouldn't say I'm an expert at c#, but I understand it well enough to make a browser with cef sharp(Chromium Embedded FrameWork). I would think I would use FFMPEG or direct show but I don't understand the first thing of those to be honest or if there is even a .NET wrapper for them (there probably is though I would be surprised if there isn't). I have done research but none of it has answered my question.


Solution

  • DirectShow can be used for this. It's a framework where you connect devices, codecs and file writers as nodes in a graph where edges are streams of data between them.

    DirectShow graphs

    You can learn DirectShow on MSDN site and there is a nice C# wrapper called DirectShow.NET and also a graph editing application GraphEditPlus where you can build such graphs with your mouse, see all the relevant properties and matching filters, and then it can generate C# code that builds the graph using aforementioned .NET library. Windows SDK contains some sample filters and I remember there was a sample of a filter for capturing screen and turning into a video stream that you can feed to a codec and file writer.