Capture Live Video from Various Video Devices

Introduction

This is an attempt to create an application that captures live video from a video capture device and USB-attached WebCam together in the same application. While developing my project, I needed to capture the video from various video devices, including TV. Although I found some sources for capturing video, they were not sufficiently efficient. That prompted me to develop my own independent application. Initially, "LiveVideo" detects the availability of the video capture card and WebCam whether attached or not. Otherwise, it shows the message. Most of the API functions used are from the DirectX SDK.

Steps to Use

  1. Create a Dialog-based application.
  2. Insert a Picture control 320x240 pixels in size.
  3. In the properties of the Picture control, set TYPE as "Rectangle" and COLOR as "Black."
  4. Add the files "CaptureVideo.cpp" and "CaptureDevice.h" to your project.
  5. Add "CaptureVide.h" into your implementation header file.
  6. Create an Object of the class "CCaptureVideo" using the Class wizard.
  7. Link the strmbasd.lib, wmvcore.lib, and wmstub.lib libraries in your project settings.

Now, using the object, invoke the InitializeVideo(HWND hWnd) function to initialize the video.

HRESULT hr = capVideo.InitializeVideo(hWnd) ;

Where "hWnd" is the window handle of the picture control.

  • StartSVideo()—To start capturing from SVideo.
  • StartCompositeVideo()—To start capturing from Composite Video.
  • StartTVTuner()—To start capturing from TVTuner.
  • StartWebcam()—To start capturing from WebCam.

IMPORTANT

Don't forget to unintialize the video by using UnInitializeVideo() before you destroy your application.

Requirements

  • Video capture card. I've tested with the "WinFast TV2000 XP WDM Video Capture" card. I hope it will work with all video capture cards.
  • USB cam.
  • You need to install DirectX, which is available freely from Microsoft. You can download DirectX 9.0 from Microsoft.
  • For development, install DirectX 9.0 SDK. You can download DirectX 9.0 SDK from Microsoft.

I hope this article is of some use to you. I will add configuration settings of the video features and video quality in my next version. Feel free to use these classes as you like. Any comments or improvements would be appreciated.



About the Author

Dillip Kumar Kara

I'm working as a Software Engineer at Princeton, New Jersey, USA.

Downloads

Comments

  • capture USB cam

    Posted by wael on 09/27/2012 04:26am

    hello.. thank you for this application and for your code source. In fact, am not fluent in the image processing and i need to develop an application with USB webcam using c++ (including the OpenCV libraries). Unfortunately when i compile, the compiler starts the integrated camera. so can you help me please to solve this problem?! best regard :)

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: December 11, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Market pressures to move more quickly and develop innovative applications are forcing organizations to rethink how they develop and release applications. The combination of public clouds and physical back-end infrastructures are a means to get applications out faster. However, these hybrid solutions complicate DevOps adoption, with application delivery pipelines that span across complex hybrid cloud and non-cloud environments. Check out this …

  • On-demand Event Event Date: October 29, 2014 It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this webcast, Gene Kim discusses these survey findings and shares woeful tales of artifact management gone wrong! Gene also shares examples of how high-performing DevOps …

Most Popular Programming Stories

More for Developers

RSS Feeds