Click here to Skip to main content
15,122,251 members
Articles / Programming Languages / C#
Article
Posted 26 Nov 2020

Tagged as

Stats

6.8K views
543 downloads
11 bookmarked

Video Screen Capture - GetIt

Rate me:
Please Sign up or sign in to vote.
3.58/5 (8 votes)
26 Nov 2020CPOL5 min read
A simple no-frills Video Screen Capture app that records your screen activity to a .AVI file
This app uses an easy interface to quickly record a video of your screen activity. It makes use of SharpAVI AVIWriter and a HotKey hook to end recording.

Introduction

Every morning, I crawl out of sleep and power up my PC but for days now, I've been dreading the approach of my SnagIt Video Screen Capture - Free Trial expiration date... the countdown is actually quite frightening. I don't know if I can get another free trial or if I will ever be able to record my awesome Solitaire games to upload to my dedicated niche viewers who also dread the end of such wonderful video diversions. I've been getting stomach ulcers wondering what to do about it! And I understand how my fans can be as equally devastated by all this, I mean, who doesn't love watching someone else play Solitaire? But don't get me wrong, I could fork over the $65.00 dollars for a license fee, but eh! I'm waaaay too cheap for that.

So, this morning it just occurred to me, "why don't I make my own?" duh!

So, I spent a few hours on the idea this afternoon and came up with a decent product.

Image 1

This picture is the stuff of nightmares ... but no more!

You can see a quick sample video below:

Background

There are a lot of great Video Screen Capture apps available. Snag-It, Bandi-Cam are just two that I've 'tested'. And they have lots of features and tools. There are probably dozens of others that are just as good. They all cost under $100.00 to buy and most will let you swap your license to a different machine without any trouble. VSDC has a free video sampler which is pretty good too and it complements their entire suite of available free software including a Video Editor which I am quite fond of.

VSC - GetIt is similar to all of these with the exception that it records your captured video exclusively in AVI format and has (needs) only the most rudimentary interface. No frills, no problems.

Using the App

Launch the app and you'll see its form appear on your screen. Press the big round button and you'll be provided with a cross-hairs to select the rectangular region of your screen which you want to record. Just press down on the left Mouse button at one corner of the region you want to record and hold the button down until you're happy with your choice.

The recording will begin as soon as you release the mouse button.

You can only set the recording's Frame Rate before a recording begins, so be sure to set the appropriate value for what you want first or it will be the default 10FPS.

Click the same button again and your recording will stop.

The information provided in the message box at the conclusion of your recording tells you the number of frames and time period recorded. But if your hardware isn't up to it, it's likely the captured video is actually shorter than the time spent recording it. (I'll explain below why this happens.) So take a note of the time and when you edit your project, slow down the AVI file's frame rate in your project to match the time spent recording it and you should not have any problems.

And you no longer need to worry about the expiration of your Free-Trial. No license required.

The context menu on the form's heading will let you quit the app.

Pressing the Control-Shift-Home key combination will Hide/Recall the app at any time.

You cannot run two instances of this app simultaneously or either/both will crash.

The Code

There's not much to it. I've been working on my Animation Editor project and started tinkering with AVI files. That's coming along great. And in the process, discovered I can not only capture the screen but save it to an AVI file. So, that's pretty cool.

The opening interface is just a border-less form with a fill-docked picture box that displayed a picture of the screen before the app itself appears. Then the mouse draws the cross-hairs/rectangle until you release the mouse and the recording begins after a messagebox. Easy-peasy.

The recording is on a timer.

C#
public class classRecordingInfo
{
    public string filename = "";
    public int numFrames = 0;
    public int FrameRate = 10;
    public string Time = "";

    public classRecordingInfo()
    { }

    public string Message
    {
        get
        {
            return "Video Recording complete:"
                        + "\r\n\tFilename: " + filename
                        + "\r\n\tFrameRate: " + FrameRate.ToString()
                        + "\r\n\tNum Frames: " + numFrames.ToString()
                        + "\r\n\tTime:" + Time;
        }
    }

    public string TimeLength(long lngMillis)
    {
           //excised for brevity
    }
}

Your computer may be too busy to respond to the Timer's Tick event or too slow to actually capture the image fast enough to keep up with the timer's unprecedented lightning pace of 10 Frames Per Second. When this happens, it will record fewer frames than the stated 10 frames per second, but GetIt will continue to add frames to the AVI file which is formatted at 10FPS. This means that when you play the file in a VideoPlayer, it will run at 10FPS but those frames will have been captured and time periods exceeding the 100ms each frame required to be recorded and the resultant video will be shorter in length than the time it took to record it. This issue is hardware dependant and there is probably a way to stream-line how this app records your video. If I find out something better, I'll update this article to reflect my findings.

Until then, just use a third party app to stretch it out to the appropriate length before you convert it to MP4 and that should take the dings out of it.

The class...

C#
classAVI_Handler

...uses the AVIWriter object from SharpAvi library and the actual AVI-writing business I sourced and modified from an example.

I only worked on this for about 3 hours this afternoon. It works pretty good. There aren't the ex-illion tangled features which projects like the Sprite Editor or the Animation Editor have which created all-too-many headaches in developing and debugging, so I don't foresee any unexpected bugs to creep up.

History

  • 26th November, 2020: First published
  • 27th November, 2020: I give you ... a button!

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Christ Kennedy
CEO unemployable
Canada Canada
Christ Kennedy grew up in the suburbs of Montreal and is a bilingual Quebecois with a bachelor’s degree in computer engineering from McGill University. He is unemployable and currently living in Moncton, N.B. writing his next novel.

Comments and Discussions

 
QuestionBy the way, the real solution is just a one-liner Pin
Sergey Alexandrovich Kryukov4-Jan-21 12:54
mvaSergey Alexandrovich Kryukov4-Jan-21 12:54 
QuestionMessage Closed Pin
30-Nov-20 7:00
professionalGlamajk30-Nov-20 7:00 
QuestionReplace the AVI code with H264 code Pin
Shao Voon Wong27-Nov-20 16:08
mvaShao Voon Wong27-Nov-20 16:08 
AnswerRe: Replace the AVI code with H264 code Pin
Christ Kennedy28-Nov-20 2:51
mvaChrist Kennedy28-Nov-20 2:51 
GeneralRe: Replace the AVI code with H264 code Pin
Shao Voon Wong28-Nov-20 2:59
mvaShao Voon Wong28-Nov-20 2:59 
GeneralRe: Replace the AVI code with H264 code Pin
Christ Kennedy28-Nov-20 4:05
mvaChrist Kennedy28-Nov-20 4:05 
QuestionOBS Studio? Pin
Susheel26-Nov-20 22:59
MemberSusheel26-Nov-20 22:59 
AnswerRe: OBS Studio? Pin
Christ Kennedy27-Nov-20 6:07
mvaChrist Kennedy27-Nov-20 6:07 
QuestionHow to launch the app Pin
RasikaMani26-Nov-20 22:04
MemberRasikaMani26-Nov-20 22:04 
AnswerRe: How to launch the app Pin
Christ Kennedy27-Nov-20 6:05
mvaChrist Kennedy27-Nov-20 6:05 
QuestionDLL Pin
Rinaldo196126-Nov-20 21:49
MemberRinaldo196126-Nov-20 21:49 
AnswerRe: DLL Pin
Christ Kennedy27-Nov-20 6:03
mvaChrist Kennedy27-Nov-20 6:03 
oh wow,
I didn't realize ... I'll post them today.
my code is perfect until i don't find a bug...

SuggestionSome screen recorder alternatives Pin
RickZeeland26-Nov-20 20:45
mveRickZeeland26-Nov-20 20:45 
PraiseRe: Some screen recorder alternatives Pin
Sergey Alexandrovich Kryukov26-Nov-20 22:33
mvaSergey Alexandrovich Kryukov26-Nov-20 22:33 
GeneralRe: Some screen recorder alternatives Pin
Christ Kennedy27-Nov-20 6:00
mvaChrist Kennedy27-Nov-20 6:00 
AnswerAVI?! :-) Pin
Sergey Alexandrovich Kryukov26-Nov-20 19:27
mvaSergey Alexandrovich Kryukov26-Nov-20 19:27 
GeneralRe: AVI?! :-) Pin
Christ Kennedy27-Nov-20 5:59
mvaChrist Kennedy27-Nov-20 5:59 
GeneralRe: AVI?! :-) Pin
Christ Kennedy27-Nov-20 6:01
mvaChrist Kennedy27-Nov-20 6:01 
GeneralRe: AVI?! :-) Pin
Sergey Alexandrovich Kryukov27-Nov-20 6:08
mvaSergey Alexandrovich Kryukov27-Nov-20 6:08 
GeneralMessage Closed Pin
26-Nov-20 19:19
MemberMember 1500427026-Nov-20 19:19 
SuggestionSome comments Pin
Michael Haephrati26-Nov-20 13:11
professionalMichael Haephrati26-Nov-20 13:11 
GeneralRe: Some comments Pin
Christ Kennedy26-Nov-20 14:35
mvaChrist Kennedy26-Nov-20 14:35 
AnswerRe: Some comments Pin
Sergey Alexandrovich Kryukov26-Nov-20 19:29
mvaSergey Alexandrovich Kryukov26-Nov-20 19:29 
GeneralRe: Some comments Pin
Christ Kennedy27-Nov-20 5:57
mvaChrist Kennedy27-Nov-20 5:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.