[Vorbis] Stream "Saving" and Excerpting...

Ralph Giles giles at xiph.org
Tue Sep 27 21:31:22 PDT 2005


On Tue, Sep 27, 2005 at 07:41:12PM -0400, Jason M. Sullivan wrote:

> I'm working with a streaming Ogg Vorbis system where I'm taking the stream
> output (from a darkice server) and saving it to hour-long files, then
> reassembling excerpts from these files (sometimes spanning two or three)
> into a single file for playback.
> 
> I've got two problems (well, related to this, but anyway).
> 
> 1) The "chunk" files I'm saving into have mangled headers.

Mangled as in missing? one has to take special care to prepend
the bitstream headers before starting a new spool file. vcut
is a start on how to do this, but doesn't cover all the edge
cases, so watch out there. That's why it's not enabled in the
default build. :)

> 2) The "reassembled" files also have mangled headers.

Again, you'll have to be more specific about "mangled how"
before we can help, unless it's just a consequence of the
above.

> Now, I didn't write the code that does this (it's some python mess), but
> I'm rewriting the assembler part and starting from the source code for
> "vcut".  The problem with that is that "vcut" seems to use several API
> calls not documented in the API documentation...
> 
> vorbis_synthesis_headerin()
> vorbis_synthesis_init()
> vorbis_block_init()

These are part of the libvorbis API, which has no documentation.
(As opposed to libvorbisfile and libvorbisenc.) You have to make
do with the header file "vorbis/codec.h" and the example source.

Documentation patches welcome. :)

> I'm also wondering if I'm going about this all wrong, since there doesn't
> seem to be any easy way to do what I'm doing.  All the API calls seem to be
> centered on encoding and decoding, rather than simply cutting and splicing
> encoded packets.

Yes, you should be able to do the break and reassembly without using
libvorbis at all (although it can be helpful for parsing the headers).
For most streams, you can just cut and paste at Ogg page boundaries,
prepend/strip the pages with the header packets as necessary, and
call it done. There are again edge cases; it depends on your source
whether you'll have to work harder than that.

You might also look at the icecast code, which does stream assembly
in a different context. There's also mod_annodex and mod_oggchef,
which essentially already do what you're talking about, but have
different code bases (read: utility libraries). They might be worth
a look as well.

  http://svn.annodex.net/
  http://svn.xiph.org/trunk/oggdsf/src/tools/mod_oggchef/

Hope that helps, and feel free to follow up if you have further
questions.

 -r


More information about the Vorbis mailing list