Click here to Skip to main content
15,885,956 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

I would like to create an avi-file from a sequence of images. The images are stored as "cppBITMAP2.bmp" (during the loop the image gets updated). In this loop I want to create a video from these images.

What I have tried:

I found this: A simple interface to the Video for Windows API for creating AVI movies from individual images
Here, I tried to use the code without MFC from the comments but it did not work.

I copied the relevant part of my code (at least I think it is the relevant part) which uses the aviUtil.h file from the comment of the link):

SetDIBitsToDevice(_backbuffer,x,y,width,height, 0, 0, 0, (UINT)height,
     data, &bmi, DIB_RGB_COLORS);
 vbitmap = CreateDIBitmap(_backbuffer, &bmi.bmiHeader, CBM_INIT/*0*/, data,
     &bmi, DIB_RGB_COLORS);
 PBITMAPINFO bbitmap = CreateBitmapInfoStruct(this->_window, this-
     >_backbitmap);

 CreateBMPFile(this->_window, /*L*/"cppBITMAP2.bmp", bbitmap, this -
     >_backbitmap, this->_backbuffer);

 lpbi = (LPBITMAPINFOHEADER)GlobalLock("cppBITMAP2.bmp");
 ADD_FRAME_FROM_DIB_TO_AVI(lpbi, data, "DBI", 10);


Here, I get an access violation error and the created avi-File is empty. The lines for the bitmap creation work well. Did I call the
ADD_FRAME_FROM_DIB_TO_AVI
function wrong?

I am completely new to c++ and would be really grateful for your help.
Posted
Updated 4-Jun-19 11:35am

This isnt to hard, because AVI is a container format and you only need to init it and and some frames You may find some information in the article A class to easily generate AVI video with OpenGL and Video for Windows.

Tip: the first pixel of the first frame (so the top-left) is setting the transparent color.
 
Share this answer
 
Comments
Member 14478761 4-Jun-19 14:25pm    
That is what I tried (I thought). START_AVI() and STOP_AVI(), which are also in my code, I just did not post it. The creation seems to work somehow because I can create the file but there is no data inside.

I read the link and tried the example but here I get many errors (I use VS 2013) so if the approach I tried can work I would prefer using this. Is it possible like that? Did I miss something important?

I have no idea about your hint. Is the "data" input wrong and I need to point to something else?
I got the solution. I placed the code in the wrong place and misinterpret the error message.

Thank you for your help.
 
Share this answer
 
Comments
Member 15718771 18-Sep-22 9:22am    
It would be nice to actually show the solution you got.

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900