[Vorbis] Using decoding vorebis from a Vorbis / Theora Video

Charles Mason charlie.mas at gmail.com
Tue Feb 20 12:41:40 PST 2007


Thanks again for the help Ralph its been very useful. After a fair bit
of work I have managed to get it writing the stereo PCM data out to a
raw file, which Audacity successfully imports and plays.

I was unable to get the data out of the PCM out function. When I read
it back in c# the data was really large. not between 1 and -1. Not
sure why, probably something to do with importing into manged memory.

Anyway in the end I used the method in the decoding example to convert
each sample into a 16bit short. I have added an extra method to my
version of the library. It returns a single dimension short array
containing the converted samples. The method has the channel number as
a parameter. So for a stereo file I just call the routine once for
each channel. The function itself gets the data from the standard
PCMout function.

Having to modify the library is not a problem for me, as I already had
to compile it with an extra source file which is auto generated by
SWIG (a library interface generation tool) to make the c# interface
easier. So for each library (libogg, libvorbis, libtheora), I just
have to recompile them with one extra source file. Hopefully these
wrapper functions will continue to work with subsequent updates to the
libraries (as they are based on the stranded external functions).

So far performance looks pretty good especially for theora, where I
have tried using some HD footage. Although I will have to see how it
is when I finally have everything playing at the right speeds and
synced up.

Once I have it fully working and the source tided up I hope to open
source the c# library I have created to play Ogg Vorbis/Theroa videos
and audio files. So hopefully others trying to play Ogg video from a
.Net language can easily use the reference libraries (with a slight
modification).

Charlie


More information about the Vorbis mailing list