[Openal] Using ffmpeg

Chris Robinson chris.kcat at gmail.com
Sat Jul 19 19:55:43 PDT 2008


I've put up a simple program on the OpenAL Soft site showing how you can use 
ffmpeg to load/stream any format its capable of decoding (which can be quite 
a few, including Ogg, MP3, AC3, WMA..).

http://kcat.strangesoft.net/openal.html#tutorials

The code (alFFmpeg.c) is basically split into two parts. The first is the 
helper functions which handles dealing with ffmpeg, its packet and decode 
functions, opting to expose a simpler interface to get an audio stream in a 
file and getting specified amounts of uncompressed data from it. These 
functions are largely copyable as-is for use in other programs.

The second part is the app itself, which implements a streaming player using 
the helper functions. The player itself shows how to accurately time from an 
OpenAL stream, and features gapless playback between multiple files that use 
the same output format (yay feature creep). It is also able to handle 4 and 
5.1 channel source playback via AL_EXT_MCFORMATS.

While the code may not be too basic, it is filled with comments, so it should 
make following and understanding it somewhat easier.

Comments/critique about the code are welcome.


More information about the Openal mailing list