[vorbis] Encoding question
Michael Smith
msmith at labyrinth.net.au
Wed Mar 13 00:06:40 PST 2002
At 06:24 PM 3/12/02 -0500, you wrote:
>Hello,
> I'm working on a game and I want to encode all the sound files that I
>have (probably over a 100) with Ogg Vorbis. Most of these sound files are
>really small, about 3 - 6kb each. Each sound file contains a word, i.e.
>"cat", "bat". When I encoded some of them I noticed that the ogg file is
>never smaller than 4kb, even if the original wav file was less than 4kb. I
>saw in the libogg documentation that an ogg page is typically 4kb. So I'm
>assuming that because of that, the smallest a file can ever be is always
>4kb.
>Is there any overhead that can be removed during the encoding or is there a
>setting that could get the encoding to have a smaller page size, thereby
>generating a file less than 4kb?
Other people have given some answers, but I'll go into a bit more detail
here.
The page size (as documented) is the typical size - but pages CAN be
smaller - and they are, in cases like really short files.
The main overhead here is the headers. There are three header packets:
primary header (very small), codebook header (big. Usually near 4 kB),
and the comment header (tiny if you don't add any comments. Obviously,
it grows if you do).
Whilst this overhead can't be removed, if you have a controlled
environment (such as a game), it's very possible to work around this,
with some minor tool modifications.
First, I'll make the assumption that you use the same encode settings
(and encoder version) for every ogg file - if that isn't true, this
technique won't work.
Encode a file as normal. Strip off the first 3 packets (the 3 headers),
and store these seperately. Store the rest of the file as normal (but
note that normal players won't be able to play these, as the headers
are missing). Repeat (except now just discard the headers, as they'll
be the same for the other files) for every other file.
Now, you have the headers seperately, then lots of very small files
containing only the vorbis audio packets.
When decoding, submit the header packets directly to the decoder
(you'll need to use libvorbis directly for this, rather than vorbisfile
- but that's reasonably straightforward). THEN start sending the audio
packets to the decoder as you normally would.
Michael
<p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis
mailing list