Re: AVIStreamRead Fails
- From: "Carsten A. Arnholm" <arnholm@xxxxxxxxxx>
- Date: Sat, 10 Mar 2007 00:06:09 +0100
Hi
Looks like you don't provide a buffer to contain the data (parameters 4 and 5)?
lpBuffer should not be NULL in AVIStreamRead I think.
--
Carsten A. Arnholm
http://arnholm.org/
N59.776 E10.457
Kyle Katarn wrote:
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
- References:
- VfW : AVIStreamRead Fails
- From: Kyle Katarn
- VfW : AVIStreamRead Fails
- Prev by Date: Re: WMV Codec distribution
- Next by Date: Re: AVIStreamRead Fails
- Previous by thread: VfW : AVIStreamRead Fails
- Next by thread: Re: AVIStreamRead Fails
- Index(es):
Relevant Pages
|