creating AVI from BMPs prob

Hi !

I'm currently trying to speed up the AVI writing process in my project. So far I've been using cvVideoWriter but this turns out to be a bit slow. Now I'm using code I found on this website:

http://www.wischik.com/lu/programmer/avi_utils.html

and I'm stuck because everything works fine until I've chosen the compression type from the menu. The program hangs/ aborts. The avi file itself is written but with no content (0 kb). The console window does not show an error message. Btw, using the OpenCV version instead works but it's slow as I mentioned.

Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[...]

sprintf(load,"%s/result.avi",samp.c_str());
fperiod=1000/fps; //fps is frames per second, e.g. 25
HAVI avi = CreateAvi(load,int(fperiod),NULL);

while(true)
    {

[unrelated code, editing frames from capture]
// saving the current frame:

sprintf(load,"%s/image.bmp",samp.c_str());
			cvSaveImage(load,framex);
			HBITMAP hbm=(HBITMAP)LoadImage(NULL,load,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
  if (uu==0) // Set up compression just before the first frame
  { AVICOMPRESSOPTIONS opts; ZeroMemory(&opts,sizeof(opts));
    SetAviVideoCompression(avi,hbm,&opts,true,hwnd);
  }
  AddAviFrame(avi,hbm);DeleteObject(hbm);

[unrelated code] uu=uu+1;

}

CloseAvi(avi);



I don't know if it will be faster if it works but I hope so. Does anybody see why the code above is not working?

Best
dwu
Last edited on
I've just tried ''uncompressed'' from the menu and it worked. So it seems that xvid compression (what I had selected before) is not supported by avi_utils. Plus what's more important it's just as fast/slow as cvVideoWriter...

other info that maybe helpful to others: it seems that if you choose ''uncompressed'' from the OpenCV menu the video created is faulty. So if you want to make uncompressed AVIs you should use avi_utils while for xvid videos you should work with cvVideoWriter.
Last edited on
Topic archived. No new replies allowed.