2

I am new in developing UWP apps. I have recently developed desktop application for screen recording which captures the screen, records audio. For this I have used some filters from the DirectShowLib, WindowsMediaLib.

Now to build the same application in UWP, I am not getting any clue from where to start and also not finding the API's in UWP that will help me. Anyone knows, please help me...

Raghva
  • 65
  • 1
  • 8

2 Answers2

5

The accepted answer is no longer true. As of April 2018 version of Windows 10, version 1803, you can now capture the screen and record audio.

Screen capture (Windows.Graphics.Capture namespace)

The part that I haven't figured out is how to record that to an mp4 file.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
James Hancock
  • 3,348
  • 5
  • 34
  • 59
  • Unfortunately new functionality still has important limitations (even through essentially is likely to be a wrapper for good old Desktop Duplication API). – Roman R. Oct 30 '18 at 14:04
  • Such as what's missing? Just starting to write an app that does this. – James Hancock Oct 30 '18 at 14:10
  • For example, ["This namespace currently requires you to be running Windows 10 Pro or Enterprise."](https://learn.microsoft.com/en-us/uwp/api/windows.graphics.capture) – Roman R. Oct 30 '18 at 14:11
  • OK. I can live with that. Thanks for the heads up. Weird that it has that limitation though. Good to know. Now if I could just figure out how to dump the frames into an mp4 stream I'd be set. – James Hancock Oct 30 '18 at 14:13
  • You should be able to use Media Foundation Sink Writer (MSDN reference: [MFCreateSinkWriterFromURL function](https://learn.microsoft.com/en-us/windows/desktop/api/mfreadwrite/nf-mfreadwrite-mfcreatesinkwriterfromurl)) which is available in UWP and manages H.264 encoding with MP4 multiplexing. – Roman R. Oct 30 '18 at 14:16
  • Any pointers to where in UWP? I can find the MediaCapture and there is one for custom sinks but I can't find any documentation about it and how to use it to write frames etc. Basically I have a GraphicsCaptureItem and a Direct3d11CaptureFramePool that is spitting out frames. I'm trying to use those 2 objects to write the frames to an mp4 file with audio. Documentation is SPARSE. – James Hancock Oct 30 '18 at 14:32
  • The API function from link above is UWP safe. It basically offers you method to take input samples on input and then it does the rest of the work ending up in MP4 file. Input samples can carry D3D11 surfaces as frames and it's a direct match to what the new API is capturing (Direct3D11CaptureFrame's Surface property). – Roman R. Oct 30 '18 at 14:37
  • Sorry, I'm not following. I can't find MFCreateSinkWriterFromUrl anywhere in the UWP namespaces. I sort of got it to work with MediaClip but it blows up with too many frames. Any help greatly appreciated. – James Hancock Oct 30 '18 at 17:08
  • 1
    To avoid this getting really long and it's relevant extension to this question, here's a new one: https://stackoverflow.com/questions/53070359/uwp-how-to-record-screen-and-save-as-mp4-file – James Hancock Oct 30 '18 at 18:08
  • Just want to point out that this API is no longer limited to Windows 10 Pro/Enterprise. It works on Home too. – Yoshi Askharoun Apr 13 '20 at 21:07
  • Does that mean under Windows 10 any version we can capture any screen with audio in uwp with a nice UI to be able to pick what we want to capture? – James Hancock Apr 13 '20 at 21:13
  • This solves the video part of the question, but not the audio. `AudioGraph` API does not seem to have any way to specify current audio output device as input for the graph. – LOST May 23 '22 at 03:32
1

There's no way to do that in UWP. Please see the answer here. The answer there talks about taking a screenshot, but the same is true for capturing system video/audio output in a UWP app:

As a sandbox technology it will not allow capture the whole system's screen. It does not meet the security reason of UWP sandbox. If you want to do this you may have to consider develop a desktop app and then convert and use our Desktop Converter technology.

Of course this way your app won't be truly portable, it will only work on desktop Windows, but as I understand from your question, you already have such a desktop app developed. This way, you can convert it to a UWP app so you'll be able to upload it to the Store, thus increasing the reach (in terms of users) of your application.

Péter Bozsó
  • 1,294
  • 8
  • 18
  • 2
    The Desktop Bridge doesn't *"convert"* a desktop application to UWP, though. It merely gives it an app identity, allowing it to use those UWP APIs that need an app identity. The application is still your regular desktop application. – IInspectable Sep 03 '17 at 20:15
  • Yes, it's very important to point this out, as the documentation I referred above does too: "While the term "Converter" appears in the name of this tool, it doesn't actually convert your app. Your app remains unchanged. However, this tool generates a Windows app package for you." – Péter Bozsó Sep 04 '17 at 08:44