Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1449

VB6 - Screen Capture to Video, Grab a Window or the Full Screen & Encode to MP4 Video

$
0
0
This is more of a continuation to my previous Windows Graphics Capture project but with enough modifications to warrant a new thread. Now, in addition to capturing any top level window or the whole monitor and displaying it in a PictureBox, the captured frames are also fed in real time into a "MediaStreamSource" object that takes care of encoding and saving them to an MP4 video file.

To start capturing a window just have the program in the foreground (to maintain focus), hover the mouse over the window you want to capture and press "Enter". The same goes for capturing the monitor if you have more than one. The capture process works even in background if you want to do something else in the meantime. The video file will be saved in the "App.Path" folder with a name generated from the current date and time.

There are just three custom properties in the video encoding class, BitRate, FrameRate and FileName (if you're not happy with the defaults). I've seen that a BitRate of 3Mbps and a FrameRate of 60FPS produce nice quality, decent size files.

The program responds to external events such as the target window being resized or closed and there is also the possibility to pause and resume the capture process. The pause duration is not included in the video file so on playback it would seem the action skipped right ahead! :bigyello:

Name:  PrettyGood.jpg
Views: 53
Size:  41.9 KB

Here is the demo project: ScreenCaptureToVideo.zip

I've done quite a bit of testing and it seems to work fine so far but I'd like to know if there are any bugs. Most of the API functions involved are asynchronous in nature meaning they don't return a value right away but also they don't block the execution like VB6 does. Implementing such asynchronous behavior in VB6 (with delegate callbacks as to keep the UI responsive) has been challenging without resorting to the infamous "DoEvents" which I wanted to avoid at all costs! :bigyello:
Attached Images
 
Attached Files

Viewing all articles
Browse latest Browse all 1449

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>