Blue Theme Orange Theme Green Theme Red Theme
 
Dundas Dashboard
Home | Forums | Videos | Photos | Downloads | Blogs | E-Books | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Login Close
User Id:
Password:
 
Forgot Password
Forgot Username
Why Register
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
 Resources  
Close
 Our Network  
Close
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:
Technologies: .NET 2.0, Windows Forms,Visual C# .NET
Total downloads : 1209
Total page views :  17153
Rating :
 4.75/5
This article has been rated :  4 times
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
DesktopRecorder.zip
 
Become a Sponsor


Related EbooksTop Videos

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.


Login to add your contents and source code to this article
 [Top] Rate this article
 About the author
 
Sateesh Kumar
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.
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today.  With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications.  Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
Clickatell's SMS Gateway
Clickatell's Developer Solutions allow you to SMS enable any website or application via a range of API's. Learn More about our API connections.
Free access to .NET Memory Management video
Everything you need to know about Garbage Collection, Temporary Objects, Fragmentation, Finalization and common causes of memory leaks in .NET. Watch the video here.
Microsoft Visual Studio 2010
Microsoft Visual Studio 2010 offers more to developers than any other Visual Studio release. Work more productively and collaboratively-with greater control over your work at every step. The Beta 2 can give you a head start on achieving efficiency.
 
   Print Read/Post comments Post a comment  Rate  
   Email to a friend  Bookmark  Similar Articles  Author's other articles  
Download Files:
DesktopRecorder.zip
 
 Post a Feedback, Comment, or Question about this article
Subject:  
Comment:  
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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | 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 | Delete | Modify | 
Thanks by Nur On September 14, 2009
This is very helpful tyvm Mr.Sateesh =)
Reply | Email | Delete | Modify | 

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Suggest an Idea  |  Media Kit
Current Version: 5.2009.6.2
 © 1999 - 2009  Mindcracker LLC. All Rights Reserved