Discussion:
AVIStreamRead fails
(too old to reply)
Kyle Katarn
2007-03-07 20:37:22 UTC
Permalink
I've reduced the problem to this small function. It calls these
successfully:
AVIFileInit();
AVIFileOpen( &aviFile, fname, OF_READ | OF_SHARE_DENY_NONE, NULL );
AVIFileGetStream( aviFile, &audioStream, streamtypeAUDIO, 0 );

Then it calls
AVIStreamRead(audioStream, 0, AVISTREAMREAD_CONVENIENT, NULL, 0, &n,
NULL);

and fails with the mysterious AVIERR_ERROR. I can play the video fine, and
other
players will play the video and audio. I'm only having problems getting the
audio
data. I hope someone knows why AVIStreamRead() is failing.



/*******************************************************************************
tries to read the audio data from a .avi file
*******************************************************************************/

void OpenAVI2(char *fname) {
unsigned char *buf;
long n;
int status;

memset(&audioInfo, 0, sizeof(AVISTREAMINFO) );
aviFile = 0;

AVIFileInit();

status = AVIFileOpen( &aviFile, fname, OF_READ | OF_SHARE_DENY_NONE,
NULL );
assert(status==0);

status = AVIFileInfo(aviFile, &fi, sizeof(AVIFILEINFO));
assert(status==0);

status = AVIFileGetStream( aviFile, &audioStream, streamtypeAUDIO, 0 );
assert(status==0);

status = AVIStreamInfo( audioStream, &audioInfo, sizeof(AVISTREAMINFO) );
assert(status==0);

audioStreamStart = AVIStreamStart(audioStream); // 0
audioStreamEnd = AVIStreamEnd(audioStream); // 226062

status = AVIStreamReadFormat(audioStream, audioStreamStart, NULL, &n);
// n = 30
assert(status==0);

achunk = new BYTE[n];

status = AVIStreamReadFormat(audioStream, audioStreamStart, achunk, &n);
assert(status==0);

audioFormat = (LPWAVEFORMAT)achunk;
AVIStreamFormatSize(audioStream, 0, &n); // returns n = 30

status = AVIStreamRead(audioStream, 0, AVISTREAMREAD_CONVENIENT, NULL, 0,
&n, NULL);
switch(status) {
case 0: // ok
bp = 0;
break;
case AVIERR_BUFFERTOOSMALL:
bp = 1;
break;
case AVIERR_MEMORY:
bp = 2;
break;
case AVIERR_FILEREAD:
bp = 3;
break;
case AVIERR_ERROR:
bp = 4; // <<<<<<<<<<<<<<<<<<<<<< GETS HERE
break;
default:
bp = 5;
break;
}

return;
}
The March Hare [MVP]
2007-03-07 21:04:48 UTC
Permalink
Post by Kyle Katarn
I've reduced the problem to this small function. It calls these
AVIFileInit();
AVIFileOpen( &aviFile, fname, OF_READ | OF_SHARE_DENY_NONE, NULL );
AVIFileGetStream( aviFile, &audioStream, streamtypeAUDIO, 0 );
First of all, your question has nothing to do with dshow.

Secondly, how did you miss all the posts in this newsgroup that say "This
newsgroup is no longer active"?

I recommend you read one of them.
--
Microsoft MVPs: http://www.microsoft.com/mvp and
MVPs.org site http://www.mvps.org
My dshow site: http://tmhare.mvps.org
Loading...