[Speex-dev] newbie qs. how to seek to a point in the Speex file?

Conrad Parker conrad at metadecks.org
Wed Apr 22 04:29:25 PDT 2009

2009/4/22  <goodnewsforyou at yahoo.com>:
> Although this actually pertains to JSpeex, I am asking these questions here
> because they are general questions and also the JSpeex project does not seem
> to be supported any more.
> 1) Can the duration of the clip be stored in it? Page 24 here
> http://www.speex.org/docs/manual/speex-manual.pdf describes the format, but
> I could not see where the duration of the clip is stored.
> 2) Since the Speex compression is not linear, is it still possible (say) for
> a 60 second clip which is 60Kb, to seek accurately to 10 seconds on the
> time-line by discarding the first 10Kb of data? If there is any example of
> how to do an approximate seek, it would be appreciated.


If you're talking about Speex data in an Ogg container (which is the
format produced by speexenc) then:

1) no the duration is not explicitly stored in the Ogg Speex file. You
need to read the granulepos (timestamp, in units of audio samples) of
the last Ogg page in the stream.

2) to seek you need to seek for the Ogg page containing the data.

I suggest you use liboggz to handle the Ogg reading and seeking:
http://www.xiph.org/oggz/. Info about the seek api is in



More information about the Speex-dev mailing list