I'm starting with the theora player_example.c. I want to be able to determine the duration of the audio/video ahead of time, to be able to display it somewhere. I can't see anything obvious in ogg.h, theora.h, or vorbis.h for this. Can anyone help me with the right place to look to do this? Thanks, Ken Larson FMJ project, fmj.sourceforge.net
Ralph Giles
2007-Aug-27 11:14 UTC
[theora-dev] How to get the duration of a file or track?
On Thu, Aug 23, 2007 at 07:13:17AM -0400, Ken Larson wrote:> I'm starting with the theora player_example.c. I want to be able to > determine the duration of the audio/video ahead of time, to be able to > display it somewhere. > > I can't see anything obvious in ogg.h, theora.h, or vorbis.h for this.It's a little complicated. First you bisection-search based on the ogg page serial numbers to find all the chain segments. Then you read the bos pages for each chain segment to identify the codecs and get their granulepos mappings. Then you read the first and last data packets for each stream in each chain segment and use those to calculate the duration of each segment. The length of the ogg stream is the sum of the durations of each segment.> Can anyone help me with the right place to look to do this?You might take a look at liboggplay; it's a convenience library that does this for general streams, as well as general playback marshalling. http://svn.annodex.net/liboggplay/trunk/include/oggplay/oggplay.h HTH, -r
Shane Stephens
2007-Aug-27 17:08 UTC
[theora-dev] How to get the duration of a file or track?
ironically, oggplay_get_duration currently works for TCP streams but not local files.... Cheers, -Shane On 8/28/07, Ralph Giles <giles@xiph.org> wrote:> > On Tue, Aug 28, 2007 at 09:39:00AM +1000, Shane Stephens wrote: > > > Unfortunately, liboggplay does not provide a simple way to determine the > > length of an ogg file. > > Oops! I saw oggplay_get_duration() in oggplay.h and assumed you had this > implemented. Thanks for the correction. > > -r >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/theora-dev/attachments/20070828/7ec986c1/attachment.htm