Jochen
Jochen

Reputation: 1853

.net video record with window handle

I launch a process (iexplore.exe), I get the processID and use p.mainWindowHandle to get the window.

Now I want to record that specific window in a video file. I know how to capture a single frame in an image file.

Is it a good idea to merge all these bitmaps into an avi file myself or are there better/faster solutions? I'm working with C#

I have seen some screen recorder SDK's out there, but they charge ridiculous amounts of money.

Upvotes: 3

Views: 1248

Answers (1)

Jochen
Jochen

Reputation: 1853

For the time being I am using Aforge's AVIWriter with a timer which adds a frame to an avi file:

        writer = new AVIWriter("MSVC");
        writer.Open("test.avi", 400, 400);

        Bitmap b = new Bitmap(width, height);

        Graphics g = Graphics.FromImage(b);
        IntPtr hdc = g.GetHdc();
        bool result = PrintWindow((IntPtr)observedProcess.MainWindowHandle, hdc, 0);
        g.ReleaseHdc();
        g.Flush();

        Bitmap resized = ResizeImage(b, 400, 400);

        writer.AddFrame(resized);

Upvotes: 2

Related Questions