• Advertisement

Archived

This topic is now archived and is closed to further replies.

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

This topic is 5418 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!!! ^^

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
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-~-

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Click and drag the link into the address bar (works for IE). It''s geocities being stupid.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Or because it is downloadable, right click it and click save target as....

that always works

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Yes, this is just an example. If you compile it you will note that the performance is not very good, it skips lots of frames.

But it shows you what to call. I suggest you use 2 different threads for sound and video. Also, use a buffering approach to get better results. It is far from simple.

Good luck!

Share this post


Link to post
Share on other sites

  • Advertisement