Click here to Skip to main content
15,882,017 members
Articles / Multimedia / DirectX
Article

DirectX Video Stream and frame capture

Rate me:
Please Sign up or sign in to vote.
4.58/5 (42 votes)
12 Jul 20042 min read 655.2K   27.2K   138   115
A library that can capture video stream and frame together

Introduction

There is a tremendous job done by NET master and enhanced by Brian Low. However, I was needed a library that can continuously capture image/bitmap from the video source and record it at the same time. Then I saw the Net master's project and Brian low's project. Well, they have done a great job, but the feature was not included in the project. So I decided to add one. By the way, I saw another project that did the same function, but it was not continuously capturing the frame by triggering event, and the video capture is rather slow, it cannot produce a smooth stream. And the frame per second is rather slow too. However, it was a great effort.

Background

Actually I was just combining the samples together. So, it could be best for you all to refer back to the samples.

Using the code

Just add a button for triggering the event and the GrapImg method. Then, add another handler of the event, which I add is the CaptureDone handler.

The CaptureDone will be fired once a frame was copied from the image buffer. After that, just display the bitmap into a picture box.

C#
private void button1_Click(object sender, System.EventArgs e)
{
    capture.FrameEvent2 += new Capture.HeFrame(CaptureDone);
    capture.GrapImg();
}

private void CaptureDone(System.Drawing.Bitmap e)
{
    this.pictureBox.Image=e;
}

However, for it to work, you will have to know how to use the DirectX capture library at first. because you will have to setup the properties for a video capture to be started, and you will need to start previewing the video before the CaptureDone will be fired.

Points of Interest

Well, one thing is, it took me a lot of time reading through NET master's and Brian Low's code. Any comment, you are welcome..... thanks. Below are two links to the Brian Low's class library and NET Master's DirectShow.NET. (Thanks for the suggestion)

History

None.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Malaysia Malaysia
Please visit my website www.mbwebcreator.com for more web site information.

Comments and Discussions

 
GeneralEncountered an Error Pin
Anonymous24-Apr-05 22:06
Anonymous24-Apr-05 22:06 
GeneralRe: Encountered an Error Pin
lgs.lsg25-Apr-05 16:38
lgs.lsg25-Apr-05 16:38 
GeneralRe: Encountered an Error Pin
hpAng10-May-05 0:29
hpAng10-May-05 0:29 
GeneralRe: Encountered an Error Pin
999ny9992-Sep-05 16:59
999ny9992-Sep-05 16:59 
GeneralRe: Encountered an Error Pin
lgs.lsg2-Sep-05 17:30
lgs.lsg2-Sep-05 17:30 
GeneralFrame capture using Audio/Video Namespace Pin
Member 107701712-Apr-05 5:20
Member 107701712-Apr-05 5:20 
GeneralRe: Frame capture using Audio/Video Namespace Pin
lgs.lsg18-Apr-05 0:37
lgs.lsg18-Apr-05 0:37 
GeneralRe: Frame capture using Audio/Video Namespace Pin
hpAng10-May-05 0:30
hpAng10-May-05 0:30 
GeneralRe: Frame capture using Audio/Video Namespace Pin
Agibald29-Sep-06 5:34
Agibald29-Sep-06 5:34 
GeneralRe: Frame capture using Audio/Video Namespace Pin
lgs.lsg29-Sep-06 9:39
lgs.lsg29-Sep-06 9:39 
GeneralRe: Frame capture using Audio/Video Namespace Pin
supra5623-Sep-06 4:09
supra5623-Sep-06 4:09 
GeneralPreview problem Pin
Nicklasson7-Apr-05 2:27
Nicklasson7-Apr-05 2:27 
GeneralRe: Preview problem Pin
Nicklasson7-Apr-05 3:59
Nicklasson7-Apr-05 3:59 
GeneralRe: Preview problem Pin
hpAng10-May-05 0:31
hpAng10-May-05 0:31 
GeneralRe: Preview problem Pin
Raimon8124-Sep-05 14:03
Raimon8124-Sep-05 14:03 
GeneralRe: Preview problem Pin
pOtrek1-May-06 4:59
pOtrek1-May-06 4:59 
GeneralRe: Preview problem Pin
pOtrek1-May-06 6:38
pOtrek1-May-06 6:38 
GeneralRe: Preview problem [modified] Pin
Lomis29-Jul-09 23:01
Lomis29-Jul-09 23:01 
GeneralBrightness change in a video. Pin
MarsWalker4-Apr-05 5:02
MarsWalker4-Apr-05 5:02 
GeneralRe: Brightness change in a video. Pin
lgs.lsg16-Apr-05 16:07
lgs.lsg16-Apr-05 16:07 
GeneralRe: Brightness change in a video. Pin
hpAng10-May-05 0:33
hpAng10-May-05 0:33 
QuestionHow to build a video from those captured frames Pin
OlivierMB21-Mar-05 2:20
OlivierMB21-Mar-05 2:20 
AnswerRe: How to build a video from those captured frames Pin
hpAng10-May-05 0:34
hpAng10-May-05 0:34 
GeneralRe: How to build a video from those captured frames Pin
OlivierMB17-May-05 1:46
OlivierMB17-May-05 1:46 
GeneralRe: How to build a video from those captured frames Pin
persée9-Jun-05 21:33
persée9-Jun-05 21:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.