robmikh / SimpleRecorder

A simple screen recorder using both the Windows.Graphics.Capture and Windows.Media.Transcoding APIs.
MIT License
219 stars 43 forks source link

Can you add "Pause/Resume" code in the project #10

Closed toponehhh closed 4 years ago

toponehhh commented 4 years ago

Hi, I'm trying to create a similar screen recorder uwp app for internal use. Your project given me a good demo about how to capture the screen video to a file. I'm wondering can you show me how to "pause/resume" the recording process? Thanks!

robmikh commented 4 years ago

I'm not sure that's possible using the transcoding APIs, and if it were there would be some challenges you'd have to consider (timestamps not taking the pause into account, etc.). You may be able to get something working by using a deferral when responding to the SampleRequested event on the media stream source, but that seems hacky to me.

The capture API itself can "pause" by hoarding the Direct3D11CaptureFrame objects so that there are none for the dwm to render into. This is the principle used by CaptureFrameWait to generate frames on demand.

Unfortunately pausing is outside the scope of this project given the current state of the APIs. If this becomes more doable in the future I'd be happy to revisit this. Also keep in mind that I'm by no means a media foundation expert. 🙂

toponehhh commented 4 years ago

@robmikh , thank you very much for your quickly reply. I'm also thinking a simple way to implement the "pause" function however MS provide less document about this. I just want all the capture process keep working except writing to the file while "paused" status. Can I do this by using the deferral object you mentioned? Would you please give me a section of sample code about how to use it? Thanks.