views:

1584

answers:

3

Hello everyone,

Is it easy to write some .Net code to record screen and audio (from computer mic), then output to an wmv file. Any reference code?

BTW: I searched all codes from WME SDK, no such sample code.

thanks! George

+2  A: 

Microsoft and the content mafi^H^H^H^Hindustry are trying their best to make this impossible. You will be far better of searching for "open source screen audio capture" than browsing any officially supplied documentation/example code - I would be seriously surprised if Microsoft provided anything relevant.

hlovdal
@hlovdal, 1. I just Googled for "open source screen audio capture", I find some, but not capture screen to video, but to images. 2. I read SDK document WME, it mentions recording screen + audio is a feature, but no sample code could be referenced. I believe there should be some. Any ideas? :-(
George2
No, I do not know any details.
hlovdal
+1  A: 

Check out the SDK that's available for Techsmith Camtasia:

Camtasia is a full-screen desktop recording app with support for various video and audio sources, codecs, etc., and their SDK exposes this as an ActiveX control (which you can call from .NET quite happily).

Dylan Beattie
@Dylan, I can not find any SDK documents or download link from Camtasia web site. Could you find out?
George2
I do apologize - it appears their SDK has been discontinued (http://www.techsmith.com/sdk.asp) Sorry.
Dylan Beattie
+1  A: 

There are DirectShow compatible filters for screen capture. Which will allow you to use any recording program to capture the screen content or write an application yourself in .NET (but its not easy).

The one I use is: http://www.hmelyoff.com/index.php?section=9

EDIT: I have don't have a sample or experience with the WME SDK. But I would recommend going the DirectShow route to avoid the requirement of having WME on the host system, the lack of support for it, and its just good to know DirectShow (or do it yourself) rather than some random API.

To use the Hmelyoff filter, it works just like a webcam. Its just another video capture source available to any application that wants video input. It works by just copying the part of the viedo buffer to it's output pin on each frame (using a API function like BitBlt).

Some sample code is here.

Or if you want to just interface to DirectShow, the easiest way is using a library to do the COM interaction for you. http://directshownet.sourceforge.net/ is a good one.

EDIT again: Capturing as video is the same as capturing frames. It just captures frames 30 times a second. CPU hog? It is, don't expect to get the full framerate.

If what you are asking is how to save the frames as video, then you are going to need to pass the data to a video encoder. You WILL need to interface to DirectShow to do this.

Nick Whaley
@Nick, I will take some time to study hmelyoff, and I also want to study Microsoft built-in solution at the same time. :-) Actually I read WME SDK document and it mentions it supports screen capture feature through .Net code. But I can not find any samples codes, do you have any related source codes to refer?
George2
Another question, I take 15 mins to study hmelyoff, but I did not find any start-up documents which describes the concepts/architecture of hmelyoff and a quick-start sample. All I find is list of sample code and API, they are not quite good for a beginner. Do you have any such kinds of documents to refer me to read? :-)
George2
@Nick, thanks for your comments. My requirement is not capture screen as static image, but capture as video (I want to capture movement of all windows/mouse to show some Demo of how to use some software). I read the CodeGuru document and it seems dealing with capture screen as static image, not capture as video?
George2
@Nick, using DirectShow is fine to me. Could you recommend some .Net source code (doing screen recording to a video) for me to make a reference?
George2