| |||||||||||||||||||||||||||||||
|
If you've come across a video transition or effect that your video editing software doesn't include, or if you want to create your own unique and imaginative effects, this page is for you. Creating your own effects for digital video is easy using the AVIFile functions, but the overhead code required becomes tedious. Wrapper classes, such as the ones shown here, tremendously simplify the process of creating custom effects.
NOTE: The code on this page is often slow. It is designed to be easy and flexible, not optimized for speed. It is best suited for use by programmers producing their own digital videos, not as an end-user product.
Limitations The code on this page is designed to be as simple and straightforward as possible, therefore it is limited to certain types of input videos: All videos (input and output) must be in 24-bit color! The wrapper classes will not work with palletized videos. If two input files are required for a video effect, they must have the same dimentions! The wrapper classes will not scale videos. Wrapper Classes Three wrapper classes are used to encompass the
AVIFile functions: Most of the functions in the wrapper classes are fairly self-explanitory, so they will not be covered here, but there are are few which may need some clarification:
CVideoFrame CInputVideo::GetFrame() vs.
BOOL COutputVideo::DisplayCompressionOptions(CWnd *pParent = NULL)
CVideoFrame::CVideoFrame(LPBITMAPINFOHEADER pBitmap, BOOL bNew = FALSE)
LPBITMAPINFOHEADER CVideoFrame::GetFrame() vs.
void CVideoFrame::PaintWindow(CWnd *pWnd) Creating a Simple Effect Let's look at how to create a simple video effect using the wrapper classes. First, create the CInputVideo and COutputVideo objects:
Next, display the Compression Options dialog to allow the user to change the compression of the output file:
Next, we create a CVideoFrame that we can write to, named Dest. We will initialize it with the first frame of the input video, to automatically set the dimentions and other options of the frame.
Next, we begin a loop to cycle through each frame. We then create a new CVideoFrame object, Src, containing the bitmap data from the current frame of the input video.
We can now create a loop to cycle through every pixel in the frame:
Here is where we perform the actual effect on our video frame:
Once we are done editing the video frame, we can write it to our output AVI file.
This is also a good time to update our preview dialog box:
The classes take care of the memory deallocation in the destructors, so we're done! Sample Code The sample code, available for download from this site, contains the wrapper classes, plus a simple application containing 8 custom effects. The application is designed to make adding new effects easy, but you may choose to design your own application from scratch. Remember to link your project with vfw32.lib!
| ||||||||||||||||||||||||||||||