Skip to main content

Screen capture

Capturing a video from the screen can be a useful feature for creating tutorials, recording gameplay, or capturing a video conference. In this article, we will explore how to capture a video from the screen and save it as an MP4 file using the VisioForge Video Capture SDK .Net and its VideoCaptureCore class.

To get started, we need to install the VisioForge Video Capture SDK .Net NuGet package.

Products: Video Capture SDK .Net

Sample code

Once we have installed the SDK, we can create an instance of the VideoCaptureCore class and configure it to capture video from the screen.

You can download a sample project from GitHub

You can record both the entire screen and a specific area of it.

Create a parameters class object and set the screen as a source.

ScreenCaptureSourceSettings settings = new ScreenCaptureSourceSettings(); 
settings.Mode = ScreenCaptureMode.Screen;

Set area coordinates

settings.FullScreen = false;

settings.Top = 0;
settings.Bottom = 480;
settings.Left = 0;
settings.Right = 640;

or record the entire screen:

settings.FullScreen = true;

Set frame rate.

settings.FrameRate = 25;

Capture the mouse cursor.

settings.GrabMouseCursor = true;

Apply screen capture settings.

VideoCapture1.Screen_Capture_Source = screenSource;

Set preview mode

VideoCapture1.Mode = VideoCaptureMode.ScreenPreview;

or set capture mode; set default MP4 output settings

VideoCapture1.Mode = VideoCaptureMode.ScreenCapture;
VideoCapture1.Output_Format = new MP4Output();
VideoCapture1.Output_Filename = edOutput.Text;


await VideoCapture1.StartAsync();

To stop capturing, we need to call the StopAsync() method of the VideoCaptureCore object and dispose of it.

Required redists

Visit our GitHub page to get more code samples.