View Full Version : Verifying completed AVI file
Daithipj
22nd November 2005, 12:51
I'm writing (what I thought would be) a quick app to check if an avi file is complete. Initially i was comparing the filesize in the RIFF header to the total avi file size, but it turns out this is an inaccurate way to check. Is there another field that contains the real file size? Or is there a better way to check for a complete file (when there is no crc information available to compare against)?
Inc
22nd November 2005, 13:18
imho you should check the total length of the stream. Means, do use the AviFil32.dll API where the command AviFileInfo() is included.
AVIFileInfo(PAVIFILE pfile, AVIFILEINFO * pfi, LONG lSize)Do assign the output to a pointer incl. an AVIFILEINFO Structure:typedef struct {
DWORD dwMaxBytesPerSec;
DWORD dwFlags;
DWORD dwCaps;
DWORD dwStreams;
DWORD dwSuggestedBufferSize;
DWORD dwWidth;
DWORD dwHeight;
DWORD dwScale;
DWORD dwRate;
DWORD dwLength;
DWORD dwEditCount;
char szFileType[64];
} AVIFILEINFOAs you can see there's a DWORD called "dwLength".
So you can compare the lengths in frames of your two AVI Files.
If thats your intention. Becuase .... if you want to check a reencode the filesize-matching approach is not the way as youll never end up with the same filesize like the source but imho the same amount of frames should be in your reencode. But watch out as it has been a fact that sometimes encoders do drop a few frames like known from mencoder i.E.
Daithipj
22nd November 2005, 21:25
Hmm, well i wasnt comparing two avi files, rather just to see if one avi file is complete (e.g. downloaded fully). I had a look at this field but didnt see how it correlated to the full file size (the number was rather low in proportion to the filesize).
Moitah
23rd November 2005, 05:35
I'm writing (what I thought would be) a quick app to check if an avi file is complete. Initially i was comparing the filesize in the RIFF header to the total avi file size, but it turns out this is an inaccurate way to check. Is there another field that contains the real file size? Or is there a better way to check for a complete file (when there is no crc information available to compare against)?
The way you were doing it sounds fine to me, as long as you allow the actual file size to be larger than the size in the header because VirtualDub puts an extra JUNK chunk at the end for padding. If you want to support OpenDML, you will have to look for additional RIFF 'AVIX' lists after the first RIFF 'AVI ' list and check the sizes there as well.
Daithipj
23rd November 2005, 10:54
you sir, are a god amongst men. that junk footer is indeed whats causing the discrepancy, thanks!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.