![]() ![]() See the description of the WaitForNewFrame to see how this composition texture is used. This texture can't be created until the GraphicsCaptureItem has been created and we know its dimensions. ![]() Create a texture resource and an associated render target view that will be used to copy each video frame. Allow the user to pick an item to capture by creating a GraphicsCapturePicker and calling PickSingleItemAsync.Ĭreate a composition texture. A GraphicsCaptureItem represents an item on the screen that is going to be captured, either a window or the entire screen. The helper methods used to initialize the Direct3D interfaces, CreateD3DDevice and CreateSharpDXDevice, are shown later in this article. This sample uses Direct3D to copy the pixels captured from the screen into a texture that is encoded as a video frame. Before beginning the capture process, you need to call GraphicsCaptureSession.IsSupported to make sure that the screen capture feature is supported on the current device. The code listing for SetupEncoding is shown below after the descriptions of the initialization steps.Ĭheck for capture support. This method could be called programmatically or in response to a user interaction like a button click. The SetupEncoding method described in this section initializes some of the main objects that will be used to capture and encode video frames and sets up the encoding parameters for captured video. Note that in order to reduce the size of the code listings in this article, the code in the walkthrough below omits explicit namespace references and the declaration of MainPage class member variables which are named with a leading underscore, "_". In the Browse tab search for the "SharpDX.Direct3D11" package and click Install. To install the SharpDX Nuget package, in Visual Studio select Manage Nuget Packages. To access this folder you must include the Videos Library capability. This example saves generated video files to the Videos Library on the device. In order to use the APIs in your app, you must include the Graphics Capture capability in the Package.appxmanifest file for your project. The example code in this walkthrough was created using the Blank App (Universal Windows) C# project template in Visual Studio 2019. We have tried to keep the Direct3D operations as discrete as possible to make it easier for you to substitute your own code or other libraries for these tasks. This library is no longer officially supported, but it was chosen because it's performance at low-level copy operations is well-suited for this scenario. For this example, we are using the SharpDX library to perform the Direct3D operations from C#. At a low level, this operation is done using Direct3D. Direct3D APIs are used to perform this copy operation quickly.Īs stated above, the copying of each captured frame is probably the most complex part of the implementation shown in this article.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |