ByteScout Screen Capturing SDK - C++ (unmanaged) - Capture Video From Given Region - ByteScout

ByteScout Screen Capturing SDK – C++ (unmanaged) – Capture Video From Given Region

  • Home
  • /
  • Articles
  • /
  • ByteScout Screen Capturing SDK – C++ (unmanaged) – Capture Video From Given Region

How to capture video from given region in C++ (unmanaged) using ByteScout Screen Capturing SDK

How to code in C++ (unmanaged) to capture video from given region with this step-by-step tutorial

On this page you will learn from code samples for programming in C++ (unmanaged).Writing of the code to capture video from given region in C++ (unmanaged) can be done by developers of any level using ByteScout Screen Capturing SDK. Want to capture video from given region in your C++ (unmanaged) app? ByteScout Screen Capturing SDK is designed for it. ByteScout Screen Capturing SDK is the screen video recording SDK helps in quick implementation of screen video recording. WMV, AVI, WebM output options are available with adjustable quality, video size, framerate and video and audio codec. Includes special features like live multiple blacking out of selected areas, recording from web cam as main source and as overlay, optional watermarks for output video.

This code snippet below for ByteScout Screen Capturing SDK works best when you need to quickly capture video from given region in your C++ (unmanaged) application. Follow the instructions from the scratch to work and copy the C++ (unmanaged) code. Use of ByteScout Screen Capturing SDK in C++ (unmanaged) is also explained in the documentation included along with the product.

Free trial version of ByteScout Screen Capturing SDK is available on our website. Documentation and source code samples are included.

Try it today: Get 60 Day Free Trial or sign up for Web API

CaptureFromGivenRegion.cpp
      
// CaptureFromEntireScreen.cpp : Defines the entry point for the console application. // #include "stdafx.h" #import "BytescoutScreenCapturing.dll" using namespace BytescoutScreenCapturingLib; using namespace std; void usage(ICapturer* capturer); void setParams(int argc, _TCHAR* argv[], ICapturer* capturer); int _tmain(int argc, _TCHAR* argv[]) { ::CoInitialize(0); // Create Capturer instance CLSID clsid_ScreenCapturer; CLSIDFromProgID(OLESTR("BytescoutScreenCapturing.Capturer"), &clsid_ScreenCapturer); ICapturer* capturer = NULL; ::CoCreateInstance(clsid_ScreenCapturer, NULL, CLSCTX_ALL, __uuidof(ICapturer), (LPVOID*) &capturer); if (!capturer) { _ftprintf(stdout, _T("Screen Capturer is not installed properly.")); ::CoUninitialize(); return 1; } capturer->put_RegistrationName(_T("demo")); capturer->put_RegistrationKey(_T("demo")); // Set capturing type to catRegion to capture from given desktop region capturer->put_CapturingType(catRegion); // Set capturing region capturer->put_CaptureRectLeft(25); capturer->put_CaptureRectTop(25); capturer->put_CaptureRectWidth(320); capturer->put_CaptureRectHeight(240); // Set output video width and height capturer->put_OutputWidth(640); capturer->put_OutputHeight(480); // WMV and WEBM output use WMVVideoBitrate property to control output video bitrate // so try to increase it by x2 or x3 times if you think the output video are you are getting is laggy // capturer->put_WMVVideoBitrate(capturer->WMVVideoBitrate * 2); // uncomment to enable recording of semitransparent or layered windows (Warning: may cause mouse cursor flickering) // capturer->CaptureTransparentControls = true; // set border style ?apturer.CaptureAreaBorderType = cabtDashed; // Set output file name capturer->OutputFileName = _T("Output.wmv"); // Start capturing HRESULT hr = capturer->Run(); // IMPORTANT: if you want to check for some code if need to stop the recording then make sure you are // using Thread.Sleep(1) inside the checking loop, so you have the loop like // Do // Thread.Sleep(1) // While StopButtonNotClicked if (FAILED(hr)) { // Error handling CComBSTR s; capturer->get_LastError(&s); _ftprintf(stdout, _T("Capture failed: %s\n"), CString(s)); } else { _tprintf(_T("Starting capture - Hit a key to stop ...\n")); int i = 0; TCHAR *spin = _T("|/-\\"); // Show some progress while (!_kbhit()) { _tprintf(_T("\rEncoding %c"), spin[i++]); i %= 4; Sleep(50); } // Stop after key press capturer->Stop(); _tprintf(_T("\nDone.")); getchar(); } // Release Capturer capturer->Release(); capturer = NULL; ::CoUninitialize(); return 0; }

Try it today: Get 60 Day Free Trial or sign up for Web API

stdafx.cpp
      
// stdafx.cpp : source file that includes just the standard includes // CaptureFromEntireScreen.pch will be the pre-compiled header // stdafx.obj will contain the pre-compiled type information #include "stdafx.h" // TODO: reference any additional headers you need in STDAFX.H // and not in this file

Try it today: Get 60 Day Free Trial or sign up for Web API

stdafx.h
      
// stdafx.h : include file for standard system include files, // or project specific include files that are used frequently, but // are changed infrequently // #pragma once #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. #endif #include <stdio.h> #include <tchar.h> #include <atlbase.h> #include <atlstr.h> #include <conio.h>

Try it today: Get 60 Day Free Trial or sign up for Web API

MORE INFORMATION

Get 60 Day Free Trial or Visit ByteScout Screen Capturing SDK page

Explore ByteScout Screen Capturing SDK documentation

WEB API VERSION

Sign Up for free Web API key

Explore Web API Documentation

Tutorials:

prev
next