请教,VFW视频流存储为AVI文件,应该如何做!欢迎一起讨论

请问,VFW视频流存储为AVI文件,应该怎么做!欢迎一起讨论!
我现在视频采集,压缩,显示都做好了.
   
    在视频回调函数中压缩(用的是Buf   :=   ICSeqCompressFrame(@CapVar,0,lpVhdr.lpData,@bKeyFrame,@OutActSize);)之后的数据Buf存储为AVI文件播放,但是播放不了.
 
    请知道的高手帮助解决!
    存储代码如下:
        //--------------压缩图像参数声明----------------
        //   视频数据格式
        bBitMapInFo   :   PBItmapInfo;
        OutFormatSize   :   DWORD;

        //--------------压缩图像参数声明----------------
        //--------------存储AVI文件参数声明----------------
        favifile:     IAVIFILE;
        AVIStream   :     IAVISTREAM;
        nFrames   :   Integer;
        //--------------存储AVI文件参数声明----------------
    function   TFromVdisplayWin.SaveAVIFileInit:   Boolean;
var
        szFile   :   string;
        iRes   :   Integer;
        StreamInfo   :   TAVIStreamInfo;
begin
        try
                Result   :=   False;
                AVIFileInit;
                iRes   :=   0;
                nFrames   :=   0;
                szFile   :=   SaveToAVIFile(FormatDateTime( 'hh-nn ',Now));
                iRes   :=   AVIFileOpen(fAVIFile,PChar(szFile),OF_CREATE,nil);
                Result   :=   True;
                if   iRes <> AVIERR_OK   then
                begin
                        WriteErrorFile(ErrorFile, '未连接 ', '调用AVI函数库初始化错误 ');
                        Result   :=   False;
                end;

                FillChar(StreamInfo,   sizeof(StreamInfo),   0);
                StreamInfo.fccType   :=   streamtypeVIDEO;
                StreamInfo.fccHandler   :=   0;
                StreamInfo.dwFlags   :=   0;
                StreamInfo.dwSuggestedBufferSize   :=   BmpOutInfo^.bmiHeader.biSizeImage;
                StreamInfo.rcFrame.Right   :=   BmpOutInfo^.bmiHeader.biWidth;
                StreamInfo.rcFrame.Bottom   :=   BmpOutInfo^.bmiHeader.biHeight;
                StreamInfo.dwScale   :=   1;
                StreamInfo.dwRate   :=   30;

                if   (AVIFileCreateStream(fAVIFile,   AVIStream,   StreamInfo)   <>   0)   then