Previous | Contents | Next

2.2 Using SDK

If you want to adding video capturing capability to your application, please follow this guide. It is very easy to add this feature, only take no less than 10 minutes.

This guide is only limited in creation of DirectX9 based application. Please refer to API interfaces(section 3.2) and proprietary examples, if DirectX8/10 and OpenGL is used.

  1. Copy BandiCap.h and bdcap32.dll

    Copy bdcap32.dll to the directory that exe file is located. Adding BandiCap.h to your project. Bandi Capture Library is used as DLL, It is not required to statically link(.LIB) to your project.

  2. Variables declaration

    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;
    
  3. Start capture, Stop capture

    Define capture start button. Before capturing configure which presets to use. Scroll Lock key and F11 key is prefered to start capture.

    // ...
    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 upper corner of captured video.
          // To remove logo, you may fill this function with provided license information. 
          if(FAILED(m_bandiCaptureLibrary.Verify("BCL-SDK-TRIAL", "f5b0b287")))
            ASSERT(0);
         }
    
        if(m_bandiCaptureLibrary.IsCreated())
        {
          BCAP_CONFIG cfg;
    
          // Use presets to easy configuration. As you want, you can set this configure 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 filename by using 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 read by other media players. It also can be uploaded to UCC provider such as YouTube, Naver blog, and MNCast without any post processing.

  4. Progress

    In Video Updating function of your program, call the capture function by shown 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(...);
    

    Video capturing is resource consuming task. If users forget to stop recording, storage space will be filled by the captured video.

    To prevent these problems, We recommend notifying user whether capture is progress or not. This notification is not shown in captured video file, because the capture function is called prior to notifying function.

  5. Release instance and DLL unload

    Release video library before the application ends by calling Destroy() function. BCL can call Destroy() function automatically when it destructed.

    m_bandiCaptureLibrary.Destroy();
    

Copyright(C) 2008-2019 Bandicam.com, https://www.bandicam.com
Bandi Capture Library 2.1.0.190 created : 2017-02-03  3:34:53