[Vorbis] Encoding / new comments

Ralph Giles giles at xiph.org
Sun Apr 9 19:33:07 PDT 2006


On Mon, Apr 10, 2006 at 02:48:58AM +0200, David Baelde wrote:

> I don't remember where we got the recipe for doing so, but at every
> new track we basically completely reset the encoder. It involves a
> quite costly call to vorbis_analysis_init. My question is: is it
> strictly needed ? I just want to change the metadata after all.. Any
> pointer to a good tutorial would be greatly appreciated too, learning
> from examples is nice but you never know if the example is so good..

It's not really needed if you're only changing the metadata and not the 
encoding parameters. You might try editing your vorbis_comment 
structure, and then calling vorbis_analysis_headerout() again. I've not 
checked to see if that would work, but it might. If not, you can cache 
the info and setup headers from the first time.

Then you must clear and init your ogg_stream_state with a new serialno, 
of course. Send the new header packets, and then continue by sending new 
data packets from the same encoder state.

What is going to need hacking is to get rid of the blip this will 
introduce. Vorbis packets are overlapped with the previous one, so
when the decoder overlaps the first packet of the new stream segment
with the wrong data it will create noise. To get gapless playback you'll 
have to resubmit just the right about of audio data and/or duplicate 
a packet with the granulepos fudged.

Sorry that this is just off the top of my head, but hopefully it was of 
some help. Good luck and keep us posted.

 -r



More information about the Vorbis mailing list