[ogg-dev] Reg: Finding Duration of OGA file
ogg.k.ogg.k at googlemail.com
ogg.k.ogg.k at googlemail.com
Mon Aug 11 02:05:31 PDT 2008
> How do I find the duration of a OGA file programmatically ? Please let me
> know .
For the first chain, you need to compute the length of each chain. The chain
duration is the max of all of these.
For Vorbis, the length of a stream is the difference between the granulepos
of the last packet less that of the first one, divided by the sample rate. For
Speex and/or FLAC, it's likely similar, but I do not know for certain.
If there is more than one chain, you need to repeat this for all chains, and
add the durations. Binary search may be required to get the BOS packets
for subsequent chains.
If it's a "simple" stream, libvorbisfile could tell you this easily,
though simple
ones tend to be ogg files - newer libvorbisfile can read and discard other
streams though, so may be enough.
More information about the ogg-dev
mailing list