Hello people! I'm developing a Java Ogg media player applet and I have encountered a problem while creating a progress bar. I need to know how long, in samples or seconds, the Ogg stream that I'm playing is, and I need to know it before I have downloaded the entire stream. Problem is, I don't see how I could do that. I could provide a "duration" argument, but that would make using my player quite messy, as the web masters would have to use a script to check the numbers of samples everytime they want to add an Ogg file. Do you know a way that I could get around this somehow? Maybe some header data that I have missed? If not, what is the easiest way to check the numbers of samples? Thank you so much in advance! Sincerely, Jon Kristensen
\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 skeleton? HTH, -r
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 > skeleton?yeah, and we put it in an HTTP response header too (using mod_annodex): http://wiki.annodex.net/wiki/HttpHeaders K.