Advertisement

How to play AVI file with sound in OpenGL!!!

Started by March 17, 2003 08:19 AM
9 comments, last by cggm 21 years, 11 months ago
hi all... I refer to the lesson 35 of Nehe web to play the AVI file, but the example code can''t play the AVI file with sound. Therefore, can anyone tell me how to play AVI with sound or where to get the example code, which is the best for me ^^, developed in VC++ 6.0 and OpenGL, and executed on Windows??? I will thank you very much!!! ^^
Look at the msdn sample for reading and writing avi files.

Here is the link to it: aviview.zip

v_d_d

[edited by - v_d_d on March 18, 2003 11:12:27 AM]
Advertisement
That''s a broken link... it looks like someone was messing with your sight.

-~-The Cow of Darkness-~-
-~-The Cow of Darkness-~-
Strange, it ain''t broken here... it works for me...
Mine says


We''re sorry, but this page is currently unavailable for viewing.
If this site belongs to you, please read this help page for more information and assistance.

For general questions see our main help area, or search for other member pages.


With all the geocities stuff arounf it... strange.

-~-The Cow of Darkness-~-
-~-The Cow of Darkness-~-
Can you see the main home page at?

http://www.geocities.com/v_d_d
Advertisement
Yeah, I can see the main page... I don''t know, something like this happened before. I think my internet connection is just screwed up.

-~-The Cow of Darkness-~-
-~-The Cow of Darkness-~-
Click and drag the link into the address bar (works for IE). It''s geocities being stupid.
Or because it is downloadable, right click it and click save target as....

that always works
I''ve downloaded the files and it seems pretty complicated. I''ll just run through it to see if I''ve got it all:

1) Open your video and audio streams as usual from the AVI file.
2) Get the format of the audio stream:

AVIStreamReadFormat(myAudioStream, 0, formatSize, &audioFormat);

2) Create a "myWaveOut" object:

waveOutOpen(&myWaveOut, WAVE_MAPPER, audioFormat,
(DWORD) (UINT) hwnd, 0L, CALLBACK_WINDOW)

3) Create a "waveObject" (can''t this be simplified?):

waveObject = (LPWAVEHDR)GlobalAllocPtr(GMEM_MOVEABLE | GMEM_SHARE, (DWORD)(sizeof(WAVEHDR) + AUDIO_BUFFER_SIZE)));

waveObject->dwFlags = WHDR_DONE;
waveObject->lpData = (LPBYTE)waveObject + sizeof(WAVEHDR);
waveObject->dwBufferLength = bufferSize;


4) Read a piece of audio stream data into the waveObject

AVIStreamRead(myAudioStream, position, numSamples,
waveObject->lpData,
bufferSize,
&waveObject->dwBufferLength,
&lRead);

5) Write the data in your waveObject into the your waveOut object.

waveOutWrite(myWaveOut, waveObject ,sizeof(WAVEHDR));

So that''s the answer then. The process goes:
audioStream -> waveObject -> waveOut

But I haven''t tried it yet so I don''t know if it works the way I''ve written it and it could probably be tidies up a fair amount.

This topic is closed to new replies.

Advertisement