Hi there, in fact, my purpose is to write tool which will allow one to split ogg file with vorbis audio *and* theora video codecs, but at first I'd like to understand how the splitting of Ogg Vorbis stream works. So I looked at existing tools that split Ogg Vorbis audio files, i.e. `vcut' utility in vorbis-tools package, and Ogg plugin from `libmp3splt', but I found that engine code is pretty the same. The one of the core functions of `vcut' source starts with the comment: /* Write the first stream to output file until we get to the appropriate ?* cut point. ?* ?* We need to do the following: ?* ? - Adjust the end of the stream to note the new end of stream. ?* ? - Change the final granulepos to be the cutpoint value, so that we don't ?* ? ? decode the extra data past this. ?* ? - Save the final two packets in the stream to temporary buffers. ?* ? ? These two packets then become the first two packets in the 2nd stream ?* ? ? (we need two packets because of the overlap-add nature of vorbis). ? ? ?... ?*/ So my questions are: what does "overlap-add nature of vorbis" means? Why should I copy even two last packets from first fragment of Vorbis file to the second one? Why I can't finish first fragment with n-th packet, and just start next fragment with new (n + 1)th packet? Say, I don't want to break any vorbis packet, ?don't want to cut vorbis file at *exactly* e.g. 5000 samples, and breaking stream at nearest packet's boundary is okay for me. Much thanks in advance! -- WBR, Timur
ogg.k.ogg.k at googlemail.com
2009-Jun-28 09:47 UTC
[Vorbis-dev] Splitting Ogg Vorbis file
> So my questions are: what does "overlap-add nature of vorbis" means?Decoding a Vorbis packet makes use of the two previous packets (that's also known as 'preroll'). Thus, if you're missing those packets, you'll get different data out (though I don't know *how* different that output would be). You'd need this even if you want to cut at a packet granularity.