Example Code

Desktop Capture Video Recorder

Code and Documents

Attachment

Download All

Overview

This example is a full desktop capture application, allowing you to record your screen into a video file.

I have written this example quite some time ago now, but always felt that re-writing it is too big of a burden. This afternoon however I have finally pushed myself to turn that spaghetti-code mess into something more readable (well, at least I hope so).

This application can be used to capture your desktop into an AVI video. I guess it can be quite useful if you are interested in making things like video-tutorials and etc. but feel free to use it (and most importantly change it) to your needs.


Description

In order to capture the screen I have used Windows User32.dll file that I call from within LabVIEW. Using it you can simulate PrtSc button key-press. Every time PrtSc is pressed the screen capture goes to clipboard, from which using IMAQ ClipboardToImage application acquires an IMAQ image and then AVI file is written to using IMAQ AVI2 Write Frame. This is done every defined amount of time to build a video file.

I have also implemented some additional functionality to the application such as:

  • All key-presses are recorded and shown in the video file.
  • Adjusting FPS and Quality of the image.
  • Ability to pause/resume the recording.
  • Enlarged cursor image so it's easier to follow.
  • Encoding the AVI file.
  • Ability to record only a specific area of the screen.
  • Showing file-size dynamically while recording.
  • Showing record time.
  • Ability to launch the file or explore its directory straight from the application

And many more...

Steps to Implement or Execute Code

  1. Download the VI
  2. Open it and read the Help tab for a quick How-To
  3. [Optional] Change options in settings tab to adjust the quality, FPS or file location.
  4. Run the VI. The application will start as paused.
  5. To start the screen capture hit on the Pause/Resume button or press F5.
  6. Once you are finished make sure you are on Pause.
  7. [Optional] Either run the file clicking on Open File or explore the directory by clicking on Explore
  8. To finish hit Stop (or press F6)

Couple of notes:

  • If no directory is specified the program will write video to your My Documents folder and it will be named as "file.avi".
  • Once the program starts it will overwrite the original file specified so please be careful with it.
  • If you are using multiple screens there is currently a bug that will cause mouse cursor and key-press text to appear incorrectly.

Requirements

Software

LabVIEW 8.6 or later

NI-IMAQ

Hardware

Additional Images or Video


recorder.png

recorder front.png

______________________________________________________

Mark N
Applications Engineer
National Instruments UK & Ireland

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors