At 05:59 PM 3/17/01 +0100, you wrote:>What I'd like to do is to copy a part of an Ogg/Vorbis file to a new
>file, without decoding and re-encoding (say I've got several songs
>in one long file, and I want to split them into separate files).
>Sample granularity is not required, packet granularity should do.
>
>I'm reading the Ogg documentation. I think I could write some code
>based on ogg_stream_packet{out,in}. Is this the way to go, or are
>there easier ways? Or is there perhaps already existing code for
>this purpose so I don't need to reinvent the wheel?
>
I have almost-complete code for doing this at sample granularity.
There are a couple of small bugs remaining, though. I should get
back to it some time soon - haven't touched it for a couple of
weeks. So, you could wait for that.
Alternatively, if you want to do it now, with only packet
granularity, then this is the basic approach (it's not quite as
easy as it looks at first):
extract ogg pages from input file
extract ogg packets from page
write packets to first file until you reach the split-point
now, start the second file
write the last packet from the first file into the second file
(this is needed because of the overlap-add that happens - each
sample needs data from two packets).
write the rest of the packets to the second file, being sure to
calculate a correct granulepos for each packet (this is the
deceptively hard bit)
If you don't really care about adding a few extra samples at the
start and end of the output files, you can skip most of the
difficult bits and just give it close-enough info, but that's not
recommended.
Michael
--- >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@xiph.org'
containing only the word 'unsubscribe' in the body. No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.