Screen Capture Video Recording in Visual C# (sample code) - ByteScout

Screen Capture Video Recording in Visual C# (sample code)

  • Home
  • /
  • Articles
  • /
  • Screen Capture Video Recording in Visual C# (sample code)

Screen Video Capturing SDK is a toolkit for making screen capture video software or adding screen capturing abilities to programs you develop. To perform screen video capture use the sample below. This source code shows how to capture screen video to WMV or AVI file in Visual C Sharp. 

Visual C#

using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Diagnostics;
using <span data-scayt_word="BytescoutScreenCapturingLib" data-scaytid="2">BytescoutScreenCapturingLib</span>; // import <span data-scayt_word="bytescout" data-scaytid="3">bytescout</span> screen capturing <span data-scayt_word="activex" data-scaytid="4">activex</span> object 
<span data-scayt_word="namespace" data-scaytid="5">namespace</span> <span data-scayt_word="SimpleCaptureCSharp" data-scaytid="6">SimpleCaptureCSharp</span>
   class Program
       static void Main(string[] <span data-scayt_word="args" data-scaytid="16">args</span>)
           <span data-scayt_word="CapturerClass" data-scaytid="17">CapturerClass</span> <span data-scayt_word="capturer" data-scaytid="18">capturer</span> = new <span data-scayt_word="CapturerClass" data-scaytid="21">CapturerClass</span>(); // create new screen <span data-scayt_word="capturer" data-scaytid="20">capturer</span> object
           capturer.CapturingType = CaptureAreaType.catScreen; // set capturing area type to <span data-scayt_word="catScreen" data-scaytid="25">catScreen</span> to capture whole screen
           capturer.OutputFileName = "EntireScreenCaptured.wmv"; // set output video filename to .WMV or .AVI file
           // set output video width and height
           capturer.OutputWidth = 640;
           capturer.OutputHeight = 480;
      // <span data-scayt_word="uncomment" data-scaytid="26">uncomment</span> to set <span data-scayt_word="Bytescout" data-scaytid="29">Bytescout</span> <span data-scayt_word="Lossless" data-scaytid="31">Lossless</span> Video format output video compression method
    // do not forget to set file to .avi format if you use Video Codec Name
           // capturer.CurrentVideoCodecName = "<span data-scayt_word="Bytescout" data-scaytid="30">Bytescout</span> <span data-scayt_word="Lossless" data-scaytid="33">Lossless</span>";             
           capturer.Run(); // run screen video capturing 
           Thread.Sleep(15000); // wait for 15 seconds
           capturer.Stop(); // stop video capturing