-4

I am building an application in WPF using .NetFramework. It can record full or partial desktop along with Audio to an mp4 file. Right now I am using ffmpeg for that which works fine but has certain issues.

I want to give a try to Desktop Duplication API. Most of the related repositories I find on github are several years old. Why there's very little latest information available on this topic, especially for C#? Can you share any starting points that meet my requirements?

Simon Mourier
  • 132,049
  • 21
  • 248
  • 298
Riz
  • 6,746
  • 16
  • 67
  • 89
  • 1
    [Are "how would I get started?" questions too broad?](https://meta.stackoverflow.com/q/308745/839601) – gnat Jan 02 '23 at 14:08
  • Just curious what issues you encountered with ffmpeg? I used it for the same purpose before, worked pretty well. – Evk Jan 02 '23 at 15:20
  • 1
    Desktop Duplication API works fine is fully actual and supported, but it's a native low-level API. The only "official" way of using it from .NET is to use WinRT (and C# projection like C#/WinRT). The WinRT api in question is the screen capture API (https://learn.microsoft.com/en-us/windows/uwp/audio-video-camera/screen-capture) in the Windows.Graphics.Capture namespace, only for Windows 10. This WinRT API uses Desktop Duplication native API undercovers... – Simon Mourier Jan 03 '23 at 16:59
  • ... However, integrating that with WPF is another story (WPF is stuck in year 2005 with DirectX9 and its evolution is frozen, visual integration with modern Windows tech is hard, sometimes impossible). I would use WinUI3 (with C#) instead. You can have a look at this interesting article for more info https://www.thomasclaudiushuber.com/2021/02/05/what-is-actually-the-universal-windows-platform-and-what-is-winui-msix-and-project-reunion/ – Simon Mourier Jan 03 '23 at 16:59
  • Thank you @simon-mourier for detailed info. Since it's an update to an existing app, I'll have to stick to WPF for now. After some research I am using Windows Graphics Capture API to record screen and have some success. – Riz Jan 05 '23 at 07:04
  • You can share your thoughts on that https://stackoverflow.com/questions/75014646/recording-a-region-with-windows-graphics-capture-api – Riz Jan 05 '23 at 07:05

1 Answers1

1

As one of the comments mention Desktop Duplication API is a native low-level API, check this repo https://github.com/bmharper/WindowsDesktopDuplicationSample.

I read also your comment regarding "stick to WPF", there are 2 options in my opinion.

The first one is a very simple RecordBook-Screen-Recorder, it is made in WinForms, and the UI is not in English but very easy to understand, I share it for inspiration: https://github.com/iEmreM/RecordBook-Screen-Recorder.

That said, I have previously played with Captura open source recording in .net and WPF, it can capture video and sound.

here is the repo, the latest updated 2 years. https://github.com/MathewSachin/Captura.

It is feature-rich software as well.

With that said, you might search and find something more, but you won't find complete software that has everything without issues.

In addition, check this article does not cover what you need but gives inspiration to your comment regards Windows Graphic Capture API. https://blogs.windows.com/windowsdeveloper/2019/09/16/new-ways-to-do-screen-capture/

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
  • Thanks for replying @maytham-fahmi - Yeah I have searched a lot and as mentioned in question, good C# based solutions are rare to find. First one is C++ and RecordBook is using SharpAvi, not the native API in question. I am exploring Windows Graphics Capture API, which seems to have more support and flexibility. – Riz Jan 05 '23 at 18:21
  • I got your point if I get more knowledge I will add it to my answer. – Maytham Fahmi Jan 05 '23 at 18:27