Blue Theme Orange Theme Green Theme Red Theme
 
6 Months Free & No Setup Fees ASP.NET Hosting!
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Team Foundation Server Hosting
Search :       Advanced Search »
Home » Visual C# » Enhanced Desktop Recorder in .NET using C# and Windows Forms

Enhanced Desktop Recorder in .NET using C# and Windows Forms

This application provides features that will allow Desktop recording, sharing and broadcasting etc easier.

Author Rank :
Page Views : 42857
Downloads : 3391
Rating :
 Rate it
Level : Intermediate
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
Download Files:
DesktopRecorder.zip
 
 
DevExpress Free UI Controls
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 

Nowadays, Desktop or Application sharing is common to coordinate work properly in IT as well as other fields also. Sometimes, it may require to record the Operations done by us on Desktop for future reference. I have not seen many applications which support Desktop recording, sharing and broadcasting of it. I think it's better to design an application that will do above operations little bit easier. So, I design this application in VS.NET 2005 using C# and windows forms. I will explain features provided by this application, one sample scenario where we can use this application followed by its design and coding.

Features present in this application:

  • It allows us to record the Desktop Operations.
  • It allows us to view the recordings with an inbuilt Media Player.
  • It allows us to view the List of recent recordings.
  • Inbuilt Functionality to add Audio to the Desktop recordings.
  • Inbuilt Functionality to broadcast Desktop recordings.
  • Inbuilt Functionality to see remote Desktop.
  • Inbuilt Functionality to play, pause and stop recordings.
  • Inbuilt Functionality to start, pause and stop recording.
  • Inbuilt Functionality to show recording Duration, number of users connected to broadcast (desktop sharing).
  • Easy to use UI.
  • Now, Desktop recording and sharing is just a click away from us.

Sample Scenario for using this application:

Normally, software Testers use to prepare lot of descriptive documents for a bug to explain steps to be followed in reproducing it. I believe an image is equal to 1000's word description. So, why can't a tester record the steps for reproducing the bug in a video, instead of complex documents? Around of 50 - 60% of our effort in fixing the bug will be spent in analyzing, reproducing, get clarifications from testers regarding bug. So, in order to compensate it, the best solution is to record the bug's details in a video with audio support for extra information. In this kind of situations, this application will be very handy to use. There are other cases also, where this application will be useful like analyzing complex application's functionalities etc.

Prerequisites:
 
In order to use this application, we require Media Player Encoder 9. It is an plugin for Windows media player. It can be downloaded from here:

Now, create a new Windows Application using C# in VS.NET 2005 and name it as DesktopRecorder. Add controls to Main Form (DesktopRecorder) as shown below:

Now, I will outline functionality of few main controls in the application:

ContextMenu (cxtRecordingOpts):

This Control having few menu items for following operations:

  • Start Recording --> To start recording the Desktop.
  • Pause Recording --> To pause recording the Desktop.
  • Stop Recording --> To stop & save recording the Desktop.
  • Enter Audio File Path -->  To enter Path of audio file to be used while recording as an input to it.
  • Save Current Recording --> To save current recording.
  • Broadcast --> To enable broadcast, set Port Number for broadcasting.
  • Recent Recordings --> To see list of recent recordings.

menuStrip1 (Menu Strip):

This control is having an Option Menu with following items in it:

  • Open Broadcast URL Recording --> To Set URL of broadcast for viewing in Media player.
  • Play, Pause and Stop menuitems are used in changing the state of the player.
  • Show Media Player UI --> To show/hide inbuilt media player UI.
  • Exit --> To Exit the application.

Apart from this, I added few other controls to improve UI & Functionality.

Now, add a reference to COM dll (WMEncoderLib).If not, you can access this dlls from bin folder of code attached here. This will allows us to access functionality provided by Windows Media Player Encoder.

The main functionality of this application is it will record all desktop operations in wmv format for future reference along with sharing capability at a time.

Now, I will explain coding part of this application.

On Click of Start Recording --> Here, we are creating an instance media player encoder and setting its properties like input audio, video and broadcast path etc.
Finally, Encoder will be started to start recording. I will explain functionality of this event, little bit deeper. Since, this is the core for this application:

IWMEncProfile SelProfile;

IWMEncSource AudioSrc;

try

{

    if (DesktopEncoder != null)

    {

        //Checks Whether Encoder in is paused state or not.If it paused, it //will just starts it and returns.

        if (DesktopEncoder.RunState ==  MENC_ENCODER_STATE.WMENC_ENCODER_PAUSED)

        {

            DesktopEncoder.Start();

            return;

        }

    }

    #region Default settings for Encoder.

    DesktopEncoderAppln = new WMEncoderApp();

    DesktopEncoder = DesktopEncoderAppln.Encoder;

    IWMEncSourceGroupCollection SrcGroupCollection =     DesktopEncoder.SourceGroupCollection;

    IWMEncSourceGroup SrcGroup = SrcGroupCollection.Add("SG_1");

    IWMEncVideoSource2 VideoSrc = (IWMEncVideoSource2)SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO);

    #endregion

    //Set Audio Source,if Add Audio Checkbox is checked.

    if (addAudio.Checked)

    {

        AudioSrc = SrcGroup.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO);

        if (txtAudioFile.Text.Trim() != "")

        {

            if (File.Exists(txtAudioFile.Text.Trim()))

            {

                //Set audio file path to be used while encoding or recording.

                AudioSrc.SetInput(txtAudioFile.Text.Trim(), "", "");

            }

            else

            {

                //Set to use Default audio device as input,if file does not exist.

                AudioSrc.SetInput("Default_Audio_Device", "Device", "");

            }

        }

        else

        {

            AudioSrc.SetInput("Default_Audio_Device", "Device", "");

        }

    }

    //Set Video Source:Desktop.

    VideoSrc.SetInput("ScreenCapture1", "ScreenCap", "");

    IWMEncProfileCollection ProfileCollection = DesktopEncoder.ProfileCollection;

    ProfileCollection = DesktopEncoder.ProfileCollection;

    int lLength = ProfileCollection.Count;

    //Set Profile.

    if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")

    {

        IWMEncBroadcast broadcast = DesktopEncoder.Broadcast;                                       

broadcast.set_PortNumber(WMENC_BROADCAST_PROTOCOL.WMENC_PROTOCOL_HTTP, Convert.ToInt32(txtPortNbr.Text.Trim()));

        for (int i = 0; i <= lLength - 1; i++)

        {

            SelProfile = ProfileCollection.Item(i);

            //Set selected profile as Windows Media Video 8 for Local Area //Network,if broadcasting is enabled.

            if (SelProfile.Name == "Windows Media Video 8 for Local Area Network (768 Kbps)")

            {

                SrcGroup.set_Profile((IWMEncProfile)SelProfile);

                break;

            }

        }

    }

    else

    {

        for (int i = 0; i <= lLength - 1; i++)

        {

            SelProfile = ProfileCollection.Item(i);

            if (SelProfile.Name == "Screen Video/Audio High (CBR)")

            {

                SrcGroup.set_Profile((IWMEncProfile)SelProfile);

                break;

            }

        }

    }

    //Local File to Store Recording temporarily.

    IWMEncFile inputFile = DesktopEncoder.File;

    inputFile.LocalFileName = "C:\\TempRecording.wmv";

    DesktopEncoder.PrepareToEncode(true);

    DesktopEncoder.Start();

    tmrRcCounter.Enabled = true;

    recordStarttime = DateTime.Now;

    if (toolstripEnableBroadcast.Checked && txtPortNbr.Text.Trim() != "")

    {

        //Start Timer to Count Viewers connected to Broadcast.if broadcasting is enabled.

        tmrViewerCount.Enabled = true;

    }

}

catch (Exception ex)

{

    MessageBox.Show(ex.Message);

}

On Click of Stop Recording --> Here, Encoder will be stopped for stopping recording. Later, it will popup save dialog to store the recording to a file. The path of the file, where recording is saved will be added to Recent Recordings menu.

On Click of Exit (application closing) --> Here, all recent recording's path will be added to a file for loading it later.

Steps to be followed in using this application:

  1. Start the application, than click on Start Recording to start recording of desktop operations.
  2. If you want to broadcast (to be viewed by others) this recording, than goto Broadcast menu and click Enable Broadcast, set port number to be used for broadcasting. It will use HTTP protocol for broadcasting. So, it won't be blocked by firewalls. Than, start the recording. So that, at a time you can record your desktop operations and broadcast it also.
  3. If you want to add Audio to your recording, than goto Enter Audio File Path and set audio filename along with its path. Than, start the recording. So that, at a time you can record your desktop operations along with audio appended to it.
  4. Then, Click on Stop Recording when you are done with it. It will popup a save dialog to select filename for saving the recording.
  5. Then, you can play those recordings by going to Recent Recordings and selecting that filename from it.
  6. If you want to watch broadcasting of the desktop, than goto Options Menu and select set URL of the Broadcast ( like http://10.100.1.100:8000) and hit Enter. It will start playing the broadcast.
  7. In Status bar, you can see recording duration followed by number of users connected to your broadcast.

Finally, I added some code to enhance UI of the application. And, the final output will be like this:

We can still enhance this application by improving UI, Broadcast Quality etc.

By using this application, we can record all your Desktop activities. I am attaching source code for further reference. I hope this code will be useful for all.

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Sateesh Arveti
I hold Bachelors degree in Computer Science along with MCSD,MCTS and MVP for the year 2009. Areas of Interest: C#, WPF, WF, silverlight, ASP.NET, Oracle and SQL Server.

Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
DevExpress Free UI Controls
Become a Sponsor
 Comments
Can we Enhance it to record webpages by bhavin On August 29, 2008
Hello, First of all Thanks for the Very Good Application..... Also I would like to ask that can we enhance it to record full webpage or the portion of a webpage. Thanks.
Reply | Email | Modify 
Double Click not working by Pat On September 10, 2008
Has anyone found a way to get the double click to work when the Recorder is running?
Reply | Email | Modify 
Audio + Video Capture ? by Habeeb On January 25, 2009
Wow. This is a very useful article put in a very simple way. Thank you Sateesh for sharing your expertise. I would like to know, rather than choosing an audio file, is there an option to record the live audio of the system which is in sync with the video capture. For example if I need to record my voice using microphone as part of the video is it possible?
Reply | Email | Modify 
Re: Audio + Video Capture ? by Sateesh On February 3, 2009
Hi Habbeb,
We can record ur voice using Microphones.Its already existing functionality
Reply | Email | Modify 
Re: Re: Audio + Video Capture ? by Habeeb On February 3, 2009
Yes. Thanks a lot. I noticed that only later on.

Anyway, this article has been of great help dude. Good job!!!
Reply | Email | Modify 
can we capture a specific region? by Shanthi On March 27, 2009
Hi,Thank you for giving us this excellent article.Its working fantastic.... I need your suggestion here. when we are recording it also captures the action when we stop recording. I want to avoid this. How can i do this? Is it posiible to capture a specific region or how we can do that? Please help me out.....
Reply | Email | Modify 
problem at add ddl by venkat On April 27, 2009
when i add WMEncoderLib.dll its not loaded please any tell me the steps how do it. tell me the total process of this
Reply | Email | Modify 
Re: problem at add ddl by Gerard On April 29, 2009
Venkat

You need to install the Encoder SDK. Be sure to use IE to download and install as firefox will not install it correctly. Once you have achieved that, simply go back to your references in the application and refresh, or click on the previously missing references and they will have been registered for you.

Hope that helps

Gerry (Eplixo)
Reply | Email | Modify 
Clarification by Gerard On April 29, 2009
Sateesh this is a first class example of simplicity and focus of a specific topic and well presented and the contribution is much appreciated. Two issues arise that perhaps you might be able to clarify.

First the matter of broadcasting protocol remains unclear. If you could elaborate a little more on the steps needed to initiate this and what a client (other PC or internet user) would need to do to access the (live) broadcast.

Secondly I am assuming that a broadcast would reduce the output and so cause the screen size to be reduced to accomodate the fps. This may be the reason for the reduction from higher quality to a 320 x 240px screen on broadcast.

Finally the Screen_Capture is perfect for tutorials, but would this be possible to achieve application specific (exclusive of the desktop) recording and broadcast. This would perhaps enable the objective I have of desktop sharing.

Gerry (Eplixo)
Reply | Email | Modify 
About Digital clarity by venkat On May 2, 2009
Hi This application is working fine but clarity of recorded vedio is not good. what will we do for clarity video. when i run this application other folder and files are not opened.
can any one tell me the solution thanks in advance.
Reply | Email | Modify 
need to broadcast the video by abhishek On August 21, 2009
 Hi,

i tried to deploy this application working pretty fine but i cannot broadcast the live stream... is there something that this article doesnot say about broadcasting..
Reply | Email | Modify 
Windows 7 not working by Job On September 10, 2009
On Windows 7 im getting this error:
Retrieving the COM class fatory for component with CLSID xxxxxxx failed due the following error: 80040154
Reply | Email | Modify 
Thanks by Nur On September 14, 2009
This is very helpful tyvm Mr.Sateesh =)
Reply | Email | Modify 
help me by suhas On May 13, 2010
i choosen dis as my project
i need details about encoder.
some q
1>which compression technique used and how differ from others.
2>size of sceenshot and how many screenshots taken in 1 sec.
3>which part of code take sreanshots and compress it video.

i searched lot on net but could't find any about encoder .
atleast send me kink or url , where i can find answers.
Reply | Email | Modify 
video format by niks On June 18, 2010
in  which video format it save the video.
Reply | Email | Modify 
Broadcasting over internet by Psychic On August 15, 2010
sateesh, i must commend your work on this project (not well advertised though) and i'm glad that this thread is still alive and kicking. i have been trying to do a similar project and i was successful in recording desktop a/v using wmencoder the same way you've done it. however i reached your thread when i was trying to stream the recorded video live on internet. i'd appreciate some insight on this from you or anyone on this thread.
Reply | Email | Modify 
format and size by Psychic On August 15, 2010
i'd also like to know if we can record any other a/v format other than wmv and is there any way to keep the file size low without losing on quality.
Reply | Email | Modify 
Not found link by mohmaed On September 16, 2010
this is a very very very good program
but the link you posted above (Media Player Encoder 9) is not found
please send update it
thanks you
mohammed sameeh
Reply | Email | Modify 
HRESULT: 0xC00D0072 by Marijke On September 28, 2010
Hello, great feature!!
I tried to run the program in VS2010 and Vista and I get the following error: HRESULT: 0xC00D0072 Anyone has found a workaround for this?
Thanks.
Reply | Email | Modify 
More light on Broadcasting function by Frederic On October 25, 2010
Hi Satish,
This article is really good. Can you please give some more light on braodcasting function over http. Thank you.
Reply | Email | Modify 
Problem with windows 7 by Arno On February 15, 2011
Hi Sateesh First of all, thanks a lot for the awesome example, it really works well. My question is this: I can't seem to get this program working on windows 7. I can record the video, but as soon as I want audio, the program crashes. Has anybody figured out how to get this working? Thanks for all your help in advance. Arno
Reply | Email | Modify 
how to capture specific window operation by thimmanagouda On March 18, 2011
suppose a notepad,a wordpad,firefox are opened.....if i want to record only operations done on notepad......plz give some help on how to capture the specific window
Reply | Email | Modify 
not working... by sajan On March 24, 2011
when clicking start recording..it says Retrieving the COM class factory for component with CLSID {36D27C48-A1E8-11D3-BA55-00C04F72F3...
Reply | Email | Modify 
not saved by sajan On March 24, 2011
the recorded thing is not saving ...
Reply | Email | Modify 
RQ: not starting the Recording by SAIDI On April 28, 2011
Hi Satheesh, Thank full to you to present your valuable coding here . when i click on Start button this error is occuring please help me about this error . Retrieving the COM class factory for component with CLSID{632B606B-BBC6-11D2-A329-006097C4E76} due to the following error 80040154
Reply | Email | Modify 
Not working play button by SAIDI On April 28, 2011
Hi Satheesh, Thank full to you to present your valuable coding here . when i click on Start button this error is occuring please help me about this error . Retrieving the COM class factory for component with CLSID{632B606B-BBC6-11D2-A329-006097C4E76} due to the following error 80040154
Reply | Email | Modify 
vlc does not support audio or video format "mss2" by Mason On May 10, 2011
Hello,your good application is helpful to me for my current screen recorder module. At the same time, i have a vlc media player embeded in my project, i'd like to use libvlc to resolve streaming video over lan. my vlc can play video with black screen. How can i resolve the bug? Is it possible to convert wmv(mss2) to in a regular wmv file? Thanks in advance.
Reply | Email | Modify 
6 Months Free & No Setup Fees ASP.NET Hosting!
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.