PDA

View Full Version : AVIStreamGetFrameOpen crashes or returns NULL when XviD open (Delphi)


zonderz
7th December 2006, 02:58
Hi guys

Did anyone solve this known problem when trying to get bmp from AVI and if file is XviD coded AVIStreamGetFrameOpen fails?

Ive searched many sources but didnt find right desision.

Only one dude decided that strange bug, but code is in VB, and i need in delphi
http://www.shrinkwrapvb.com/avihelp/avihlp_3.htm

his demo program (http://www.shrinkwrapvb.com/avihelp/avitutr3.zip) extracts frames form any AVI, i tried DivX, Xvid, HDTVRips, avis with 2,3,4 audio tracks, uncompeled avi's - all work fine

I read his sources but didnt solve the problem

That's why Im here.
If this task is too hard and undecided, if you know how to easily extract a custom frame from any coded type of AVI without showing video it would be very helpful. Ive tried DirectShow (vidgrab.dll, dspack) but there's many bugs with AVI opening, especially with multiple audio tracks

Only one component works fine but has no sources and costs too much (mmtools, MMAVI component)

PS. For whom who dont understand my bad english. I need to find right and final desision how extract frames from any type of AVI or multiple AVIs in Delphi.

Thanx for trying help anyway...

esby
11th December 2006, 10:29
1- Can you upload a video sample that make your application crashes?

2- If you have such sample, check if lbkiller is able to load the avi correctly or not? (check the link on my sig).

esby

Bester
11th December 2006, 13:23
I don't know Delphi, but in C this works. Return values should also be checked...

AVIFileOpen(&AVIFile, "C:\\...\\test.avi", OF_READ, NULL);
AVIFileInfo(AVIFile, &FileInfo, sizeof(AVIFILEINFO));

AVIFileGetStream(AVIFile, &pAviStream, streamtypeVIDEO, 0);
AVIStreamInfo(pAviStream, &StreamInfo, sizeof(AVISTREAMINFO));
start = AVIStreamStart(pAviStream);

BITMAPINFOHEADER BIH;

BIH.biSize = sizeof(BITMAPINFOHEADER);
BIH.biWidth = FileInfo.dwWidth;
BIH.biHeight = FileInfo.dwHeight;
BIH.biPlanes = 1;
BIH.biBitCount = 24;
BIH.biCompression = BI_RGB;
BIH.biSizeImage = 0;
BIH.biXPelsPerMeter = 0;
BIH.biYPelsPerMeter = 0;
BIH.biClrUsed = 0;
BIH.biClrImportant = 0;

pVideoFrame = AVIStreamGetFrameOpen(pAviStream, (LPBITMAPINFOHEADER) &BIH);
lpBitmapInfoHeader = AVIStreamGetFrame(pVideoFrame, start);

zonderz
14th December 2006, 18:21
i found how to decide my problem!!!

now i use
frame:= AVIStreamGetFrameOpen(AVIStream, PBITMAPINFOHEADER(AVIGETFRAMEF_BESTDISPLAYFMT))

instead of

frame:= AVIStreamGetFrameOpen(AVIStream, nil)

there are no errors now

But... How to do the main form not freezes when opening avi or extracting avi frames Especially when opening uncompleted avis...

Does anyone know how to do a callback for this avi function?
thanx