I have written a program that reads frames from an avi, manipulates them, and then writes them to an output avi. Everything works fine for 73 frames, but on frame 74 AVIStreamGetFrameOpen returns nothing rather than a pointer to a getframe object. Anyone know what I am doing wrong? Here is the main code of my program:
Code:avi_stat=AVIFileOpen(&InFile,InName,OF_SHARE_DENY_WRITE,NULL); avi_stat=AVIFileInfo(InFile,&InFileInfo,sizeof(InFileInfo)); FrameWidth=InFileInfo.dwWidth; FrameHeight=InFileInfo.dwHeight; avi_stat = AVIStreamOpenFromFile(&InStream, InName,streamtypeVIDEO,0,OF_SHARE_DENY_WRITE,NULL); avi_stat=AVIStreamInfo(InStream,&InStreamInfo,sizeof(InStreamInfo)); CurrFrame=AVIStreamStart(InStream); LastFrame=AVIStreamEnd(InStream)-CurrFrame; avi_stat=AVIStreamFormatSize(InStream, 0, &lStreamSize); hr=AVIStreamReadFormat(InStream,0,&InBmp,&lStreamSize); OutBmp=InBmp; OutBmp.biCompression=0; OutBmp.biSizeImage=(OutBmp.biWidth * OutBmp.biHeight *3); avi_stat=AVIFileOpen(&OutFile,OutName,OF_WRITE|OF_CREATE,NULL); _fmemset(&OutStreamInfo,0,sizeof(OutStreamInfo)); OutStreamInfo.fccType=streamtypeVIDEO; OutStreamInfo.fccHandler=0; OutStreamInfo.dwScale=1; OutStreamInfo.dwRate=InStreamInfo.dwRate; OutStreamInfo.dwSuggestedBufferSize= (InBmp.biWidth*InBmp.biHeight*6); OutStreamInfo.dwLength=InStreamInfo.dwLength; SetRect(&OutStreamInfo.rcFrame,0,0,FrameWidth,FrameHeight); fbuff=new unsigned char[OutStreamInfo.dwSuggestedBufferSize * sizeof (char )]; hr=AVIFileCreateStream(OutFile,&OutStream,&OutStreamInfo); _fmemset(&opts, 0, sizeof(opts)); if (!AVISaveOptions(NULL, 0, 1, &OutStream, (LPAVICOMPRESSOPTIONS FAR *) &aopts)){} hr=AVIMakeCompressedStream(&CompressedStream, OutStream,&opts,NULL); hr=AVIStreamSetFormat(CompressedStream,0,&OutBmp, OutBmp.biSize+OutBmp.biClrUsed*sizeof(RGBQUAD)); for(CurrFrame=0;CurrFrame<LastFrame;CurrFrame++) { pgf=AVIStreamGetFrameOpen(InStream,&OutBmp); fbuff=(unsigned char*)AVIStreamGetFrame(pgf,CurrFrame); avi_stat=AVIStreamWrite(CompressedStream,CurrFrame,1,fbuff, InBmp.biSizeImage,AVIIF_KEYFRAME,NULL,NULL); } AVIStreamRelease(InStream); AVIStreamRelease(OutStream); AVIStreamRelease(CompressedStream); AVIFileRelease(OutFile); AVIFileRelease(inFile);
+ Reply to Thread
Results 1 to 4 of 4
-
-
I would take a careful look at AVIStreamGetFrameOpen().
What happens at frame 74, exception, crash, ect.
What happens if you start at frame 75. -
After frame 73, pgf shows a member IUknown, which has a member _vfptr which has 3 entries( [0] , [1], [2] ). Each of these shows a valid memory location. At frame 74, however, pgf show 0x00000000, a member IUnknown which shows: CXX0030: Error: Expression cannot be evaluated. If I put the following statement to just skip any frames like that:
Code:if(!pgf) { SkipFrame(); }
Steve Sherrin -
Hey. I got similar problems. God..! it was so hard to figure out.
AviStreamGetFrame doesn't "tolerate" I would say custom written streams.
F.ex written by VirtualDub. If u have long stream like 200000frames
I guarantee AVIStr... will fail. It is better to write custom stream functions
just like VirtualDub is using. Custom parsers and stream decompressors.
It's all done under IUnknown class level. Microsoft has to fix something there I think. My movies were stopping after strange but CONSTANT number of frames unless written by other program than VDub or similar.
Similar Threads
-
Reading AVI/MPG/DIVX files from a BD-R in PS3 or other
By harryman in forum Authoring (Blu-ray)Replies: 1Last Post: 4th Dec 2011, 09:40 -
Damage Disc Reading Problem
By Teac23 in forum DVD RippingReplies: 18Last Post: 20th Mar 2010, 18:03 -
Error Reading by GOM and Media Player Classic in reading MKV video
By cutefix in forum Software PlayingReplies: 1Last Post: 31st Mar 2009, 00:25 -
Problem reading media with LG RH4820v
By d1n1s in forum DVD & Blu-ray RecordersReplies: 1Last Post: 25th Jul 2008, 14:43 -
problem reading some discs
By nick6878 in forum DVD RippingReplies: 5Last Post: 3rd Jan 2008, 10:25