[ogg-dev] Finding out the duration of an Ogg stream
conrad at metadecks.org
Fri Jun 6 14:42:29 PDT 2008
2008/6/7 Ralph Giles <giles at xiph.org>:
> \On 6-Jun-08, at 1:21 PM, Jon Kristensen wrote:
>> Do you know a way that I could get around this somehow? Maybe some
>> header data that I have missed?
> No, you didn't miss anything. Ogg is designed to always be
> streamable, so the only way to get the duration is to look at the end
> of the stream.
>> If not, what is the easiest way to check the numbers of samples?
> It's a bit tedious. If you know it's a static (or at least fixed
> length) file you're pulling, e.g. from the Content-Length header, you
> can do a Range request for the last 4k or so, try to parse it for the
> timestemp (and keep backing up if you don't find it). If the serialno
> fields match, you're done, just subtract the timestamp of the first
> packet from that of the last. If not, the file is several different
> stream concatenated together, so you have to bisection search for
> where the serial numbers change and add up the individual durations.
> Might help to look at the code in vorbisfile.c and liboggz for this.
> Annodex folks, is a Content-Duration something we should define in
yeah, and we put it in an HTTP response header too (using mod_annodex):
More information about the ogg-dev