Record a video of the screen using .NET technologies
There isn’t any need for a third-party DLL. This simple method captures the current screen image into a .NET Bitmap object.
private Image CaptureScreen()
{
Rectangle screenSize = Screen.PrimaryScreen.Bounds;
Bitmap target = new Bitmap(screenSize.Width, screenSize.Height);
using(Graphics g = Graphics.FromImage(target))
{
g.CopyFromScreen(0, 0, 0, 0, new Size(screenSize.Width, screenSize.Height));
}
return target;
}
I am sure you can figure out how to capture a smaller portion of the screen, if that is needed :-).
How to capture screen to be video using C# .Net?
the answer is the Microsoft Expression Encoder. It is according to my opinion the easiest way to record something on vista and windows 7
private void CaptureMoni()
{
try
{
Rectangle _screenRectangle = Screen.PrimaryScreen.Bounds;
_screenCaptureJob = new ScreenCaptureJob();
_screenCaptureJob.CaptureRectangle = _screenRectangle;
_screenCaptureJob.ShowFlashingBoundary = true;
_screenCaptureJob.ScreenCaptureVideoProfile.FrameRate = 20;
_screenCaptureJob.CaptureMouseCursor = true;
_screenCaptureJob.OutputScreenCaptureFileName = string.Format(@"C:\test.wmv");
if (File.Exists(_screenCaptureJob.OutputScreenCaptureFileName))
{
File.Delete(_screenCaptureJob.OutputScreenCaptureFileName);
}
_screenCaptureJob.Start();
}
catch(Exception e) { }
}
How can I capture the screen to be video using C# .NET?
Your best option seems to be Windows Media Encoder.
Here are some resources:
Capture Desktop Activities As a Movie
Capture Activities on Screen in a Movie
Capture screen activities/video using WmEncoder
Capture Screen Video C# .NET in a Background Process in Windows XP
Create a Video Stream (AVI) from a Series of Images
I think this might be your best solution. Store all the .jpg's and create an avi from the command line at intervals. I don't see how creating video on the fly would produce a "lightweight" solution.
Related Topics
How to Reduce Memory Consumption of PDFptable with Many Cells
How to Concatenate Two Ienumerable<T> into a New Ienumerable<T>
Calling Async Methods from Non-Async Code
Convert an Object to an Xml String
How to Ensure a Timestamp Is Always Unique
How to Await a List of Tasks Asynchronously Using Linq
Run Selenium Tests in Multiple Browsers One After Another from C# Nunit
Rx: How to Respond Immediately, and Throttle Subsequent Requests
Can a Dbcontext Enforce a Filter Policy
What's Wrong with These Parameters
Dependency Injection - New Instance Required in Several of a Classes Methods
How to Send an Email in .Net According to New Security Policies
Login Using Google Oauth 2.0 with C#
Is There a Serializable Generic Key/Value Pair Class in .Net
How to Make My Windows Form App Snap to Screen Edges
Do Interfaces Derive from System.Object? C# Spec Says Yes, Eric Says No, Reality Says No