Introduction
This is my first article on this site. I wanted to capture screen activities as a Movie. While looking for it I found Windows Media Encoder 9. Which was free and had this facility. While looking into it, I found its SDK and I started looking into it. It is quite interesting. So I made this small sample after looking into the API and seeing some samples in C#.
Prerequisites
You will be needing Windows Media Encoder 9 Series
http://www.microsoft.com/windows/windowsmedia/9series
/encoder/default.aspx
and SDK
http://www.microsoft.com/windows/windowsmedia/9series
/encoder/extensible.aspx
Using the code
Best thing about this API is that it is totally interface based WMEncoder is the main class. Set its parameters and start the encoder to start encoding. Stop it to save in file
Encoder = new WMEncoder();
Create a Source Group named SG_1 in Encoder's Collection
IWMEncSourceGroup2 SrcGrp;
IWMEncSourceGroupCollection SrcGrpColl;
SrcGrpColl = Encoder.SourceGroupCollection;
SrcGrp = (IWMEncSourceGroup2)SrcGrpColl.Add ("SG_1");
SrcVid.SetInput("ScreenCapture1","ScreenCap","");
SrcAud.SetInput("Default_Audio_Device","Device", "");
Find the profile and set Encoder's group profile from all the profiles available
// All Profiles listed
// for( i = 0 ; i < lLength - 1; i++)
// Console.WriteLine (ProColl.Item(i).Name);
lLength = ProColl.Count
for (i = 0; i <= lLength - 1; i++)
{
Pro = ProColl.Item(i);
if (Pro.Name == "Screen Video/Audio High (CBR)")
{
SrcGrp.set_Profile((IWMEncProfile) Pro);
break;
}
}
Specify header inforamtion of the Encoder. I.e. Description or Attributes.
IWMEncDisplayInfo Descr;
Descr = Encoder.DisplayInfo;
Descr.Author = "Armoghan Asif";
Descr.Copyright = "Copyright information";
Descr.Description = "Text description of encoded content";
Descr.Rating = "Rating information";
Descr.Title = "Title of encoded content";
IWMEncAttributes Attr;
Attr = Encoder.Attributes;
Attr.Add("URL", "www.adnare.com");
You may do some cropping of the Encoder if required
// Crop 2 pixels from each edge of the video image.
SrcVid.CroppingTopMargin = 2;
SrcVid.CroppingLeftMargin = 2;
SrcVid.CroppingRightMargin = 2; Specify the Local File as output. You may also set additional fields of the File, like size of file, seconds of file etc.
IWMEncFile File;
File = Encoder.File;
File.LocalFileName = @"C:\OutputFile.wmv";
Start the encoding process
// Start the encoding process.
// Stop the encoding process.
No fancy things are placed in the demo. It just illustrates the screen capture. It can be easily added in any existing application Nothing else.
bashiruddin SheikhPosted Feb 6, 2019, 2:11 AM
Hello i am getting error only window 10, please help me DesktopEncoder.Start(); 'specified-cast-is-not-valid'
mursaleenfayyaz fayyazuddinPosted Jun 12, 2015, 3:32 AM
SrcAud.SetInput("Default_Audio_Device","Device", ""); How to record audio of speakers? The code record audio from mic.
vinod jadhavPosted Oct 11, 2013, 9:43 AM
I have a problem to using this third party tool WMEncoderLib.dll for recording video desktop activity, it gives an error Encoder = New WMEncoder at this point VS.host has stopped working. Please do the needful ASAP. I am waiting for your reply
ren audPosted Sep 3, 2013, 4:03 PM
I get the same error, please help. ''i am getting following error plz help me. The system cannot find file specified. {System.ComponentModel.Win32Exception: The system cannot find file specified.} project having zero errors , when i clicks on button then this error message appears. plz help me ........... or suggest changes''
valko artemPosted Jul 4, 2013, 3:26 AM
http://img809.imageshack.us/img809/6476/w2hm.png =(
s nimsePosted May 23, 2012, 8:34 AM
i am getting following error plz help me. The system cannot find file specified. {System.ComponentModel.Win32Exception: The system cannot find file specified.} project having zero errors , when i clicks on button then this error message appears. plz help me ........... or suggest changes at"[email protected]"
Sapna SahuPosted Sep 30, 2011, 12:54 AM
its good code but its not working in windows 7
mohammed ahmefPosted Apr 9, 2010, 11:58 AM
I want code that can be capture screen as movie and can be send it by local network all that must be done by using c#.
KIRAN K SeditedPosted Nov 17, 2009, 12:20 AMEdited Nov 17, 2009, 12:21 AM
I have used this application and it works quite nice. But i noticed a major issue in this application is that mouse double click does not working while capturing screen activities. Can you help me how to solve this issue Thanx KIRAN
Niya HerePosted Aug 20, 2008, 4:44 AM
Hi, Have a small query...Pls tell me whether WMencoder saves the screen shots anywhere in the local machine? or is it directly creating the .wav file ? If it is creating temporary images/ screen shots , pls tell me where it is getting saved? And whether I can set the encoder to take a screen shot in every 2 seconds or so.. Thanks in Advance Niya
Niya HerePosted Aug 20, 2008, 4:44 AM
Hi, Have a small query...Pls tell me whether WMencoder saves the screen shots anywhere in the local machine? or is it directly creating the .wav file ? If it is creating temporary images/ screen shots , pls tell me where it is getting saved? And whether I can set the encoder to take a screen shot in every 2 seconds or so.. Thanks in Advance Niya
Niya HerePosted Aug 20, 2008, 4:44 AM
Hi, Have a small query...Pls tell me whether WMencoder saves the screen shots anywhere in the local machine? or is it directly creating the .wav file ? If it is creating temporary images/ screen shots , pls tell me where it is getting saved? And whether I can set the encoder to take a screen shot in every 2 seconds or so.. Thanks in Advance Niya
vineesh kumarPosted Apr 19, 2007, 2:55 AM
i would like to make movie from set of images. Is there any way to make using WMEncoder. It would be grateful if you can specify the solution in visual basic or visual C++. thanks vineesh
vineesh kumarPosted Apr 19, 2007, 2:52 AM
I would like to make movie from set of images. Is there way todo this using WMencoder.I would be grateful if you can suggest the solution for this in Visual basic 6.0 or visual C++ thanks vineesh
Dinh Cong ThanhPosted Jul 18, 2006, 6:50 AM
I read article about program by C# to capture screen to movie. I try doing according to this article. But programming error. You can send for me coding of whole this programming? I am waiting your reply. Thanhk you very much