Click here to Skip to main content
15,887,267 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.7K   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

 
QuestionImportant!!! Pin
Nikola8817-Mar-07 7:52
Nikola8817-Mar-07 7:52 
AnswerRe: Important!!! Pin
Andy Bejo11-Jul-07 18:28
Andy Bejo11-Jul-07 18:28 
Question!IMPORTANT! - Two Webcams Pin
ShapeScan21-Feb-07 18:30
ShapeScan21-Feb-07 18:30 
AnswerRe: !IMPORTANT! - Two Webcams Pin
seser9-Jul-07 8:19
seser9-Jul-07 8:19 
Questionvedio streaming Pin
Member 248359415-Feb-07 18:26
Member 248359415-Feb-07 18:26 
QuestionHelp me Immediately Pin
Ali Habib15-Feb-07 5:17
Ali Habib15-Feb-07 5:17 
AnswerRe: Help me Immediately Pin
optionj856-Jul-08 2:01
optionj856-Jul-08 2:01 
QuestionHow to grab frame in vb2003/vb2005.... Pin
supra5623-Sep-06 4:21
supra5623-Sep-06 4:21 
AnswerRe: How to grab frame in vb2003/vb2005.... Pin
toocrazy00715-Aug-10 5:25
toocrazy00715-Aug-10 5:25 
GeneralTaking a single frame Pin
aquilap30-Aug-06 3:11
aquilap30-Aug-06 3:11 
QuestionRe: Taking a single frame Pin
Qurex28-Nov-06 20:07
Qurex28-Nov-06 20:07 
QuestionEnhanced DirectXCapture Pin
John_Mac20-Aug-06 13:47
John_Mac20-Aug-06 13:47 
AnswerRe: Enhanced DirectXCapture Pin
supra5623-Sep-06 4:04
supra5623-Sep-06 4:04 
QuestionNetwork streaming? Pin
asp-12328-Jul-06 6:31
asp-12328-Jul-06 6:31 
QuestionRe: Network streaming? Pin
bignev7225-Jan-07 1:06
bignev7225-Jan-07 1:06 
AnswerRe: Network streaming? Pin
busyboy28-Sep-08 2:31
busyboy28-Sep-08 2:31 
GeneralRe: Network streaming? Pin
Jacob Dixon23-Apr-09 17:35
Jacob Dixon23-Apr-09 17:35 
GeneralRe: Network streaming? Pin
Job V6-Sep-09 21:23
Job V6-Sep-09 21:23 
QuestionHow to get frames when playing? Pin
ftccpig26-Jul-06 20:04
ftccpig26-Jul-06 20:04 
AnswerRe: How to get frames when playing? Pin
supra5623-Sep-06 3:58
supra5623-Sep-06 3:58 
QuestionGrabbing from MJPEG / MPEG4+ device? Pin
Blackbeard27-Feb-06 0:57
Blackbeard27-Feb-06 0:57 
QuestionCan I just let the grabbed image unchanged? Pin
ptsmy3-Nov-05 9:30
ptsmy3-Nov-05 9:30 
AnswerRe: Can I just let the grabbed image unchanged? Pin
aquilap30-Aug-06 2:51
aquilap30-Aug-06 2:51 
GeneralGrabImage Problem Pin
fcyjk,kl;27-Sep-05 23:26
fcyjk,kl;27-Sep-05 23:26 
QuestionCapturing Video Frames from web camera device using VC++ Pin
Kirubanandam2-Sep-05 4:28
Kirubanandam2-Sep-05 4:28 

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.