[Vorbis-dev] ogg_stream_flush

Monty xiphmont at xiph.org
Tue Feb 21 08:30:34 PST 2006




On Tue, Feb 21, 2006 at 10:20:12AM +0100, Joost Pennings wrote:
> While building an ogg-vorbis stream encoder, I encountered some problems
> with silence in the audiostream.
> 
> The bitrate drops to almost zero, and pages going out less then ones a
> minute what makes the stream to stop / buffer.

You are correct.  I intend to add an API call that will direct libogg
to flush either at some specified page size, or after a given period
of time to make the automagic behavior more flexible.

> In earlier postings I read that I shout use ogg_stream_flush as an
> alternative to ogg_stream_pageout, in case of silence.
> 
> My question is this; Is there any reason for not using ogg_stream_flush all
> the time. 
> 
> So what are the advantages of ogg_stream_pageout?

ogg_stream_pageout currently attempts to keep pages to an approximate
constant size (~4kB).  ogg_stream_flush will immediately flush a page,
even if it contains only a single packet or fraction of a packet.

Ogg pages introduce a roughly fixed overhead per page; they're 26
bytes each plus one byte per packet fragment.  If each of your Vorbis
packets are, say, ten bytes each, using a page per packet would nearly
triple the bitrate.

Flushing a page for every packet is perfectly valid; there's nothing
wrong with the structure or correctness of the stream.  However, you
pay a bitrate premium for doing so.

Monty


More information about the Vorbis-dev mailing list