Re: AVIStreamRead Fails



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;
}

.



Relevant Pages

  • Re: AVIStreamRead Fails
    ... AVIFileGetStream(aviFile, &audioStream, streamtypeAUDIO, 0); ... players will play the video and audio. ... I hope someone knows why AVIStreamRead() is failing. ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Problem loading audio data with AVIStreamRead
    ... AVIFileGetStream(aviFile, &audioStream, streamtypeAUDIO, 0); ... I'm only having problems getting the audio ... I hope someone knows why AVIStreamRead() is failing. ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: AVIStreamRead Fails
    ... AVIFileGetStream(aviFile, &audioStream, streamtypeAUDIO, 0); ... players will play the video and audio. ... I hope someone knows why AVIStreamRead() is failing. ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: implicit/explicit __gc/__nogc confusion wrapping a windows api
    ... class VideoStream { ... class AviFile { ... AudioStream* audio_; ...
    (microsoft.public.dotnet.languages.vc)
  • VfW : AVIStreamRead Fails
    ... AVIFileGetStream(aviFile, &audioStream, streamtypeAUDIO, 0); ... players will play the video and audio. ... I hope someone knows why AVIStreamRead() is failing. ...
    (microsoft.public.win32.programmer.mmedia)