Playing sound in AVI files

Started by
8 comments, last by mdias 18 years, 9 months ago
Sry if this has already been posted about but I searched and could not find any posts about it. I also checked numerous websites out and ran many google searches with no results. I am a High School Intern and my project involves making and running an AVI file in openGL among other things. NeHe does not explain how to get sound to play in his tutorial. I found out how to play sounds in .WAV files, but not AVI files. So if anyone can help me out i would greatly appreciate it. Thank you
Advertisement
You might want to check again because it's right here
--------------------------------A man of few words does not mean he does not have big ideas
All he does in the tutorial is play the video, he does not play sound. He takes the frames from the video and textures them, he does nothing to mess with the sound. I need to play the video and audio but I know no ways of playing sound from an AVI file.
I've never used this before but you might want to check this out. It supposedly shows how to play avi files with sound.

--------------------------------A man of few words does not mean he does not have big ideas
Okay thank you, i will check out that site and see what I can do with it. I am fairly new to programming, I have had no classes at all, everything is self taught so I do not know a lot yet.
I can't believe I didn't think of this before posting my first link. This is probably the best and the easiest way to play avi files with sound. Just remember that you'll need to link winmm.lib and vfw32.lib with your compiler.
--------------------------------A man of few words does not mean he does not have big ideas
I read through the file and i downloaded the samples and got them to compile, it plays video fine, but not audio. I went back and looked through the code and it does not get the audio format nor process the audio. (AVITest sample, not the AVIDemo sample, the avidemo throws an error in windows then i run the application that came with it.)

I been trying to modify the code a little but to play the audio, but I cannot get it to work yet, i switched AVI files making it play one of my own that i know has sound. still no sound.

I used LPWAVEFORMAT pAudioFormat = g_AviFile.GetAudioFormat(0); to get the format of the audio, that compiles fine, but i am not sure how to process and play the audio.

g_AviFile.DetermineAudioFormats
g_AviFile.GetAudioFormat
g_AviFile.GetAudioStreamCount
g_AviFile.m_pAudioStreams

Are a few functions that the program has i am just not sure how to utilze them. I realize i am a beginner in programming but all the information i learn will help me A LOT in college next year.

Thank you
Clicky
Check out the waveOut API... all you do is play the audio in waveOut, and sync the video frame position to the current audio frame position.

Check VFW for video, of course.
my_life:          nop          jmp my_life
[ Keep track of your TDD cycle using "The Death Star" ] [ Verge Video Editor Support Forums ] [ Principles of Verg-o-nomics ] [ "t00t-orials" ]
Use directshow.
You could easily (if you're already familiarized with directshow) build a custom video renderer that feeds the video data to a texture.
If you only want to render the audio then you just create the source filter and the audio renderer and call IGraphBuilder::Connect to "inteligently" connect the two filters, then you just run the graph and that's it.

This topic is closed to new replies.

Advertisement