Click here to Skip to main content
11,933,621 members (59,513 online)
Click here to Skip to main content
Add your own
alternative version


133 bookmarked

DirectX Video Stream and frame capture

, 12 Jul 2004
Rate this:
Please Sign up or sign in to vote.
A library that can capture video stream and frame together


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.


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.

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

private void CaptureDone(System.Drawing.Bitmap 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)




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


About the Author

Web Developer
Malaysia Malaysia
Please visit my website for more web site information.

You may also be interested in...

Comments and Discussions

QuestionQuestions Pin
stultzg15-Jun-15 10:22
memberstultzg15-Jun-15 10:22 
SuggestionTips and Tricks Pin
Mostafa Korashy7-Jan-15 4:23
professionalMostafa Korashy7-Jan-15 4:23 
Questioncompiler errors. Pin
jleslie4817-Dec-13 4:46
memberjleslie4817-Dec-13 4:46 
Questiongood work Pin
Lakhan Aanjana3-Oct-13 22:31
groupLakhan Aanjana3-Oct-13 22:31 
Questionchange the brightness of a running video according to a slider or a bar Pin
Member 1013160514-Jul-13 23:33
memberMember 1013160514-Jul-13 23:33 
Questionhello Pin
youshy1-Apr-13 6:11
memberyoushy1-Apr-13 6:11 
QuestionAudio Record CallBack Pin
Mihaescu Florin3-Oct-12 23:29
memberMihaescu Florin3-Oct-12 23:29 
GeneralMy vote of 1 Pin
Member 87853324-Jul-12 3:44
memberMember 87853324-Jul-12 3:44 
GeneralMy vote of 5 Pin
adeeb masoud6-Mar-12 18:11
memberadeeb masoud6-Mar-12 18:11 
Questionhow to take image by dirctx in c# Pin
morteza fakoor4-Dec-11 9:55
membermorteza fakoor4-Dec-11 9:55 
GeneralMy vote of 5 Pin
sor@t5-Jul-11 2:43
membersor@t5-Jul-11 2:43 
QuestionHow to execute the file Pin
prashantwamane1-Dec-10 19:38
memberprashantwamane1-Dec-10 19:38 
GeneralMy vote of 4 Pin
aofeng322-Nov-10 20:03
memberaofeng322-Nov-10 20:03 
Rantawesome!!! Pin
Member 36942812-Nov-10 10:50
memberMember 36942812-Nov-10 10:50 
Generalhelp! Pin
deching10-Nov-10 6:18
memberdeching10-Nov-10 6:18 
QuestionHow to get the list of all supported FrameSizes by a video device Pin
Dramirak28-Aug-10 14:46
memberDramirak28-Aug-10 14:46 
GeneralMy captured image is a little dark than video Pin
dennis.zeng30-Jul-10 18:50
memberdennis.zeng30-Jul-10 18:50 
GeneralCaptureFrame inside Thread Pin
anki12315-Apr-10 4:11
memberanki12315-Apr-10 4:11 
Generalmedia.formatPtr always null..!! Pin
uwo22-Dec-09 21:12
memberuwo22-Dec-09 21:12 
GeneralRe: media.formatPtr always null..!! Pin
zaman_7h15-Aug-11 2:43
memberzaman_7h15-Aug-11 2:43 
Generalmulti webcam show Pin
mehrdad33320-Nov-09 11:00
membermehrdad33320-Nov-09 11:00 
QuestionError HRESULT E_FAIL has been returned from a call to a COM component. Pin
Hussien.fahmy7-Nov-09 1:42
memberHussien.fahmy7-Nov-09 1:42 
GeneralVery nice work! Pin
Lomis22-Jul-09 0:28
memberLomis22-Jul-09 0:28 
Generali want text watermark over vedio Pin
Babita Shivade9-May-09 5:02
memberBabita Shivade9-May-09 5:02 
Questionmaking snapshot without preview function Pin
katran.ek3-Mar-09 4:04
memberkatran.ek3-Mar-09 4:04 
General^.^ Thanks........ Pin
Choon kiat18-Feb-09 17:00
memberChoon kiat18-Feb-09 17:00 
GeneralCapture several images with GrapImg Pin
6F2120-Jan-09 21:49
member6F2120-Jan-09 21:49 
GeneralRe: Capture several images with GrapImg Pin
kumi_aberer@hotmail.com10-Mar-09 13:39
memberkumi_aberer@hotmail.com10-Mar-09 13:39 
Questioncan not download the source code? Pin
bluewater020928-Nov-08 17:14
memberbluewater020928-Nov-08 17:14 
QuestionA dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) Pin
saravanan.rex@gmail.com21-Nov-08 1:12
membersaravanan.rex@gmail.com21-Nov-08 1:12 
AnswerRe: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) Pin
donperry12-Feb-09 7:49
memberdonperry12-Feb-09 7:49 
GeneralRe: A dynamic link library (DLL) initialization routine failed. (Exception from HRESULT: 0x8007045A) Pin
kostiak26-Jul-09 10:30
memberkostiak26-Jul-09 10:30 
GeneralError HRESULT E_FAIL has been returned from a call to a COM component. Pin
Ankita Garg20-Nov-08 2:15
memberAnkita Garg20-Nov-08 2:15 
GeneralStart() causes crash Pin
Member 320461014-Oct-08 9:30
memberMember 320461014-Oct-08 9:30 
GeneralStill unable to grab an image [modified] Pin
ChiWaiLam17-Sep-08 1:19
memberChiWaiLam17-Sep-08 1:19 
QuestionVC++ version of DirectXCapture Pin
Wilson Kopman16-Sep-08 14:39
memberWilson Kopman16-Sep-08 14:39 
GeneralColor Control Pin
renoreballos4-Jan-08 5:07
memberrenoreballos4-Jan-08 5:07 
GeneralDetect webcam Pin
Eddiema26-Dec-07 9:31
memberEddiema26-Dec-07 9:31 
QuestionDirectShow as Web Applictaion Pin
menaka.ca19-Nov-07 14:33
membermenaka.ca19-Nov-07 14:33 
QuestionHelp, Code doesn't run (DShowNET could not be found) Pin
smitti12326-Oct-07 5:17
membersmitti12326-Oct-07 5:17 
Questioncan managed C++ use this DLL? Pin
rayher20-Oct-07 4:47
memberrayher20-Oct-07 4:47 
GeneralInterlacing in fast motion Pin
brs0264-Aug-07 6:56
memberbrs0264-Aug-07 6:56 
GeneralHelp Pin
NelsonPaz26-Jul-07 14:14
memberNelsonPaz26-Jul-07 14:14 
QuestionI face aproblem in changing the video source Pin
aishar18-Jun-07 12:04
memberaishar18-Jun-07 12:04 
AnswerRe: I face aproblem in changing the video source Pin
Raghu_Super25-Sep-07 0:20
memberRaghu_Super25-Sep-07 0:20 
QuestionCapture a frame without preview Pin
RodrigoZaratin12-Jun-07 11:28
memberRodrigoZaratin12-Jun-07 11:28 
QuestionCapture audio and video from firewire dvcam Pin
Carnivash12-Jun-07 7:19
memberCarnivash12-Jun-07 7:19 
QuestionHow do i get pixel co-ordinates (pos) on clicking the frame playing in the pictureBox? Pin
Dharani_Prasad12-Apr-07 22:44
memberDharani_Prasad12-Apr-07 22:44 
QuestionHow do i play a video in the picture box? [modified] Pin
Dharani_Prasad12-Apr-07 22:39
memberDharani_Prasad12-Apr-07 22:39 
QuestionIs that possible to grap image without working with windows.form? [modified] Pin
F.E.L.I.X.24-Mar-07 12:13
memberF.E.L.I.X.24-Mar-07 12:13 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151126.1 | Last Updated 13 Jul 2004
Article Copyright 2004 by hpAng
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid