If you want to add a video capturing capability in your application, please follow this guide. It may only take less than 10 minutes.
This guide is for DirectX9 based application. If DirectX8/10 and OpenGL is used, please refer to API interfaces (Section 3.2).
Copy bdcap32.dll to the directory that *.exe file is located. Add BandiCap.h to your project.
Bandi Capture Library is used as DLL, It is not required to statically link (.LIB) to your project.
BandiCap.h file contains Utility class to help using capture library. It also defines interfaces and error codes.
You can create Capture Library instance directly, but we recommend that you use this predefined class.
Declare member variables or global variables as shown below.
#include "bandicap.h"
// ..
CBandiCaptureLibrary m_bandiCaptureLibrary;
Define the 'Start capture' button (Scroll Lock key or F11 key is recommended).
// ...
case VK_SCROLL :
case VK_F11 :
ToggleVideoCapture();
break;
// ...
void ToggleVideoCapture()
{
IDirect3DDevice9* pd3d9Device = GetD3DDevice();
// Start capture
if(m_bandiCaptureLibrary.IsCapturing()==FALSE)
{
// When initializing, load DLL and create internal instance.
if(m_bandiCaptureLibrary.IsCreated()==FALSE)
{
// If failed, check mismatching the version of BCL DLL and BandiCap.h .
if(FAILED(m_bandiCaptureLibrary.Create(BANDICAP_RELEASE_DLL_FILE_NAME)))
ASSERT(0);
// If don't call this function, BCL shows an watermark in the upper corner of captured video.
// To remove the watermark, email us at support@bandisoft.com to purchase/get the license code.
if(FAILED(m_bandiCaptureLibrary.Verify("BANDISOFT-TRIAL-200809", "e1b03d86")))
ASSERT(0);
}
if(m_bandiCaptureLibrary.IsCreated())
{
BCAP_CONFIG cfg;
//You can use a preset or set the configuration directly.
BCapConfigPreset(&cfg, BCAP_PRESET_DEFAULT);
m_bandiCaptureLibrary.CheckConfig(&cfg); // Correct wrong settings
m_bandiCaptureLibrary.SetConfig(&cfg); // Apply presets
m_bandiCaptureLibrary.SetMinMaxFPS(30, 60); // Set minimal, maximal frame rate
// Create a filename by the current time.
TCHAR pathName[MAX_PATH];
m_bandiCaptureLibrary.MakePathnameByDate(_T("c:\\"), _T("Capture"),
_T("avi"), pathName, MAX_PATH);
// Start capture
HRESULT hr = m_bandiCaptureLibrary.Start(pathName, NULL, BCAP_MODE_D3D9_SCALE, (LONG_PTR)pd3d9Device);
if(FAILED(hr))
ASSERT(0);
}
}
// Stop capture
else
{
m_bandiCaptureLibrary.Stop();
}
}
Call Stop() function to stop recording. The produced video file can be played by GOM media player or VLC media player. It also can be uploaded to YouTube without converting.
In Video Updating function of your program, call the capture function like below. You don't have to call other function to capture audio.
// update Screen
m_pd3d9Device->BeginScene();
...
...
...
m_pd3d9Device->EndScene();
if(m_bandiCaptureLibrary.IsCapturing())
{
m_bandiCaptureLibrary.Work((LONG_PTR)m_pd3d9Device);
// messaged to notify capture in progress.
DrawCaptureNotify(); // <- implement your own notification function
}
m_pd3dDevice->Present(...);
If users forget to stop recording, their hard disk drive will be full or out of space
We recommend you to notify users whether capture is in progress or not. This notification is not shown in captured video file.
Release video library before the application ends by calling Destroy() function. BCL can call Destroy() function automatically when it destructed.
m_bandiCaptureLibrary.Destroy();