Hi Ken,<br><br>The total duration of the content is not explicitly recorded anywhere in an Ogg file.&nbsp; This is why, as Ralph mentioned (and in a little more detail here), you need to:<br><br>(1) Split the content into chain segments
<br>(2) extract the first and last data packet from each segment, for all tracks<br>(3) recover / calculate the granulepos values for the first and last data packets (*)<br>(4) convert the granulepos values from the first and last data packets into time values
<br>(5) take the largest difference between start and end time as the total chain segment time<br>(6) sum the chain segment times to create the total content length<br><br>(*) granulepos values are recorded per page, not per packet.&nbsp; Hence, if the first data packet is not the last packet on the page then you will need to reconstruct a granulepos value for it.
<br><br>In practise, many libraries do not support chained ogg files due to the additional complexity that they present.&nbsp; If you are happy not to support chained oggs then you still need to do steps 2 through 5.&nbsp; However, we would recommend including support for chained oggs as they are part of the standard.
<br><br>Unfortunately, liboggplay does not provide a simple way to determine the length of an ogg file.&nbsp; Instead, you might want to look at liboggz, and in particular a utility called oggzinfo:<br><br>shans@igor:~$ oggzinfo /var/local/share/media/dart/CCFilm.ogg
<br>Content-Duration: 00:04:49.655<br><br>Theora: serialno 1433232920<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7245 packets in 1551 pages, 4.7 packets/page<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Video-Framerate: 25.000 fps<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Video-Width: 384<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Video-Height: 288
<br><br>Vorbis: serialno 0642835574<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20824 packets in 636 pages, 32.7 packets/page<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Audio-Samplerate: 44100 Hz<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Audio-Channels: 2<br><br>Please note that oggzinfo actually passes right through the file twice in order to gather these statistics - this is not necessary if you simply want to determine the Content-Duration.&nbsp; I&#39;m also not 100% sure whether liboggz correctly supports chained oggs.
<br><br>Cheers,<br>&nbsp;&nbsp;&nbsp; -Shane Stephens<br><br><div><span class="gmail_quote">On 8/28/07, <b class="gmail_sendername">Ken Larson</b> &lt;<a href="mailto:forum@larsontechnologies.com">forum@larsontechnologies.com</a>&gt; wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">


  
  

<div bgcolor="#ffffff" text="#000000">
Ralph -<br>
<br>
Thanks, that will come in handy, because I do eventually need to try to
determine duration of individual frames.<br>
<br>
Actually, I phrased my question badly though:&nbsp; What I originally wanted
to know was how to find the total duration of the movie.<br>
<br>
Thanks,<br><span class="sg">
<br>
Ken</span><span class="q"><br>
<br>
Ralph Giles wrote:
<blockquote cite="http://mid20070827180530.GA6172@ghostscript.com" type="cite">
  <pre>On Thu, Aug 23, 2007 at 07:13:17AM -0400, Ken Larson wrote:

  </pre>
  <blockquote type="cite">
    <pre>I&#39;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&#39;t see anything obvious in ogg.h, theora.h, or vorbis.h for this.
    </pre>
  </blockquote>
  <pre>It&#39;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.

  </pre>
  <blockquote type="cite">
    <pre>Can anyone help me with the right place to look to do this?
    </pre>
  </blockquote>
  <pre>You might take a look at liboggplay; it&#39;s a convenience library that 
does this for general streams, as well as general playback marshalling. 

  <a href="http://svn.annodex.net/liboggplay/trunk/include/oggplay/oggplay.h" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://svn.annodex.net/liboggplay/trunk/include/oggplay/oggplay.h</a>

HTH,
 -r

  </pre>
</blockquote>
</span></div>

<br>_______________________________________________<br>theora-dev mailing list<br><a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:theora-dev@xiph.org">theora-dev@xiph.org</a><br><a onclick="return top.js.OpenExtLink(window,event,this)" href="http://lists.xiph.org/mailman/listinfo/theora-dev" target="_blank">
http://lists.xiph.org/mailman/listinfo/theora-dev</a><br><br></blockquote></div><br>