VfW : AVIStreamRead Fails
- From: "Kyle Katarn" <kyle.katarn@xxxxxxxxxxxxxxx>
- Date: Fri, 9 Mar 2007 21:44:41 +0100
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;
}
.
- Follow-Ups:
- Re: AVIStreamRead Fails
- From: Kyle Katarn
- Re: AVIStreamRead Fails
- From: Carsten A. Arnholm
- Re: AVIStreamRead Fails
- Prev by Date: WMV Codec distribution
- Next by Date: Re: WMV Codec distribution
- Previous by thread: WMV Codec distribution
- Next by thread: Re: AVIStreamRead Fails
- Index(es):
Relevant Pages
|