Sign in to follow this  
heatstreak20

Playing sound in AVI files

Recommended Posts

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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this