[openal] FFmpeg + OpenAL - playback streaming sound from video won't work

Chris Robinson chris.kcat at gmail.com
Mon Jan 27 20:56:31 EST 2014

On 01/27/2014 11:09 AM, Jan Drabner wrote:
> Hey,
> I am decoding an OGG video (theora & vorbis as codecs) and want to show
> it on the screen (using Ogre 3D) while playing its sound. I can decode
> the image stream just fine and the video plays perfectly with the
> correct frame rate, etc.
> However, I cannot get the sound to play at all with OpenAL.
> Here is how I decode audio packets (in a background thread, the
> equivalent works just fine for the image stream of the video file):

The main thing that sticks out to me is that you seem to be returning 
one frame per buffer, and you're limited to only 4 buffers. The frame 
size can be fairly small depending on the format, so it's likely the 
queue underruns a lot.

Beyond that, it's difficult to say with just the provided code snippets. 
Is there more available to view online anywhere? If not, it may help to 
make a small test app that still exhibits the problem (easier said than 
done, I know :/).

FWIW, I do have some code available that plays movies using Ogre, 
OpenAL, and FFMPEG (and boost), and even has somewhat proper A/V 
synchronization and aspect ratio correction. However the audio code is 
heavily abstracted to the point where you don't directly see OpenAL in 
the player code, so may not be terribly useful for someone not familiar 
with the audio interface.

If you're interested anyway, you can see it here as part of the OpenMW 
code base:

More information about the openal mailing list