Click here to Skip to main content
15,900,669 members
Articles / Desktop Programming / MFC
Article

A simple interface to the Video for Windows API for creating AVI movies from individual images

Rate me:
Please Sign up or sign in to vote.
3.54/5 (18 votes)
19 May 2003 215.2K   4.3K   68   38
A simple interface to the Video for Windows API for creating AVI movies from individual images.

Introduction

This article describes a simple interface to the Video for Windows API for creating AVI movies from individual images. The idea for this code comes from a Microsoft sample that was very unfriendly to use. With that in mind, I created this code to easily create an AVI from individual images.

The steps are:

  1. include "aviUtil.h".
  2. Call START_AVI("foo.avi"); // you must include the .avi extention.
  3. Call ADD_FRAME_FROM_DIB_TO_AVI(yourDIB, "DIB", 30); // the dib is passed in as a HANDLE which can be obtained by loading the image with a Image library. (I used CxImage which is available on this site). Put this call in a while or for loop to add all the images you want to the AVI.
  4. Call STOP_AVI(); //this closes the avi and video.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
I enjoy working with C#, Java, Perl and C++

Comments and Discussions

 
AnswerRe: ADD_FRAME_FROM_ .. buffer? Pin
Rod VanAmburgh15-Jun-04 15:32
Rod VanAmburgh15-Jun-04 15:32 
GeneralRe: ADD_FRAME_FROM_ .. buffer? Pin
mound16-Jun-04 8:50
mound16-Jun-04 8:50 
GeneralRe: ADD_FRAME_FROM_ .. buffer? Pin
Rod VanAmburgh16-Jun-04 19:27
Rod VanAmburgh16-Jun-04 19:27 
GeneralRe: ADD_FRAME_FROM_ .. buffer? Pin
mound17-Jun-04 4:20
mound17-Jun-04 4:20 
GeneralRe: ADD_FRAME_FROM_ .. buffer? Pin
mound17-Jun-04 9:53
mound17-Jun-04 9:53 
GeneralRe: ADD_FRAME_FROM_ .. buffer? Pin
Rod VanAmburgh18-Jun-04 17:22
Rod VanAmburgh18-Jun-04 17:22 
GeneralRe: ADD_FRAME_FROM_ .. buffer? Pin
mound22-Jun-04 8:03
mound22-Jun-04 8:03 
GeneralCXIMAGE to AVI... Pin
sherrinmultimedia20-Oct-03 3:57
sherrinmultimedia20-Oct-03 3:57 
I have been attempting to use aviUtil to write frames from a CxImage to a specific frame of an avi. I have a CxImage called out_image, and an output stream called out_stream. my original attempt looked like this:

for(curr_frame=first_frame;curr_frame<last_frame;curr_frame++){<br />
   out_image.Save("out.jpg",CXIMAGE_FORMAT_JPG);<br />
   Results=AVIStreamWrite(out_stream,curr_frame,1,(LPBYTE)out_image.GetBits(),out_bmpHdr.biSizeImage,AVIIF_KEYFRAME,NULL,NULL);<br />
}


Unfortunately, the output video contained only black frames, not my original image. The image is correct, as out_image.Save(....) produces the correct frame. Then I found aviUtil. The problem I am having is that I believe I need to do this:

for(curr_frame=first_frame;curr_frame<last_frame;curr_frame++){<br />
   out_image.Save("out.jpg",CXIMAGE_FORMAT_JPG);<br />
   AVI_AddFrame(out_stream, curr_frame, lpbi);<br />
}

My question is how do I get the the data bits lpbi from out_image? Or is there a simple adjustment to the one line:

Results=AVIStreamWrite(out_stream,curr_frame,1,(LPBYTE)out_image.GetBits(),out_bmpHdr.biSizeImage,AVIIF_KEYFRAME,NULL,NULL);

that will make this work?
GeneralRe: CXIMAGE to AVI... Pin
Ted Ferenc20-Oct-03 4:18
Ted Ferenc20-Oct-03 4:18 
GeneralRe: CXIMAGE to AVI... Pin
sherrinmultimedia20-Oct-03 4:48
sherrinmultimedia20-Oct-03 4:48 
GeneralRe: CXIMAGE to AVI... Pin
vanamburghrod@wmconnect.com20-Oct-03 15:57
sussvanamburghrod@wmconnect.com20-Oct-03 15:57 
GeneralRe: CXIMAGE to AVI... Pin
sherrinmultimedia21-Oct-03 2:42
sherrinmultimedia21-Oct-03 2:42 
GeneralRe: CXIMAGE to AVI... Pin
sherrinmultimedia21-Oct-03 3:36
sherrinmultimedia21-Oct-03 3:36 
GeneralRe: CXIMAGE to AVI... Pin
RoyalVN6-Apr-05 21:45
RoyalVN6-Apr-05 21:45 
GeneralAudio Pin
srinivas vaithianathan27-May-03 6:24
srinivas vaithianathan27-May-03 6:24 

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.