Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AVIERR_FILEREAD when reading large AVIs with AVIStreamRead

Status
Not open for further replies.

klaushorst

Programmer
Feb 6, 2002
5
FR
Hello,
when I try to read large AVI files (> 1 or 2GB) with the MFC AVI API,
then it works without problems as long as the frame number is below of
a limit. If I'm above of a certain value, then AVIStreamRead returns
AVIERR_FILEREAD. It has something to do with a 1GB (or sometimes,
dependant of the Codec?) or 2GB limit. As long as the frames are
within the first GB of the AVI, I can read them, when they are behind
the 1 GB of the AVI, the error is returned. The sample code shows the
steps I did.
I'm wondering, that other programs (Windows MM player) have no
problems with these large AVIs. Is there a workarround for my problem?
Or am I doing something wrong? Should I use other APIs?

Thanks in advance
-Klaus Horst-

=============================================================================================
PAVIFILE pAviFile;
PAVISTREAM pVideoStream;
ULONG Result;
ULONG FrameNr;
LONG BytesRead;
static BYTE Buffer[2000000];

AVIFileInit();

// LARGE.AVI contains 9000 frames, size is 1.5GB
Result = AVIFileOpen (&pAviFile, "D:\\TEMP\\LARGE.AVI", OF_READ |
OF_SHARE_DENY_WRITE, NULL);
if (Result)
{
... cleanup, display error and return
}

Result = AVIFileGetStream (pAviFile, &pVideoStream, streamtypeVIDEO,
0);
if (Result)
{
... cleanup, display error and return
}

FrameNr = 0; // this works
FrameNr = 3000; // this works also
FrameNr = 8000; // this returns AVIERR_FILEREAD

Result = AVIStreamRead (pVideoStream, FrameNr, 1, Buffer, sizeof
(Buffer), &BytesRead, NULL);
if (Result)
{
... cleanup, display error and return
}

... cleanup and return
=============================================================================================
 
Try to read all frames of Your file like this:
if( AVIStreamEnd(&pAviFile) > 8000) {
AfxMessageBox("We check, if it really works!");
}

for (FrameNr = AVIStreamStart(&pAviFile); FrameNr <
AVIStreamEnd(&pAviFile); FrameNr ++) {
Result = AVIStreamRead(&pAviFile, FrameNr, 1, Buffer, sizeof(Buffer),
&BytesRead, NULL);
if (Result )
{
... cleanup, display error and return
}

}
If it works and AVIStreamEnd(&pAviFile) really returns a number over 8000, the Problem can be in direct access of frames with big numbers. To work around:
1. If my sample works, read all frames still frame of interest.
2. If my sample does not work, You must use another api or try to copy part of file and then use AVI - Functions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top