I have been using a screen capture utility to create animations from my linkage mechanism simulator. It worked ok but creating the animation directly is a better choice. Fortunately, Windows provides all of the tools necessary to add this directly into the program.

image

I added a Save Video option to the File menu. The ribbon bar didn’t seem like the right place for this since it is not used often and since there is no good place for it. There is no other interface for this except for a dialog box shown after a file is selected:

image

The simulation will run as if the Run button in the ribbon bar was pressed.

The animation is recorded almost directly from the window contents. The code that draws the contents is drawing into a bitmap that is then drawn into the window to avoid flicker. For the animation, I draw that same bitmap into a bitmap of the appropriate format for compressing into an AVI file.

I avoided a lot of work by using the CAviFile class that can be downloaded from the internet. Someone was kind enough to write the code necessary for creating a video file and then supply it to people like me who want to avoid duplicating so many other peoples work.

The only thing I needed to code was the bitmap handling to create the device independent bitmap of the proper format for compressing and the code to copy data to it. Of course I have to deal with creating the user interface too.

Windows comes with a few different video compression codecs, none of which are very good. I chose to use the Cinepak codec that has been around for decades since it is available on all Windows systems. I have no idea how to speed it up although it only runs slow on one of my systems as if the faster system is utilizing the graphics card for some of the processing.

This YouTube video was created with the animation feature and then uploaded to YouTube as a test. A native file is much cleaner looking since YouTube converts all video files to the favorite YouTube format. I believe that it ends up being highly compressed mpeg data.

Dave