[vorbis-dev] Play time calculation
Ralph Giles
giles at thaumas.net
Wed Oct 8 05:40:34 PDT 2003
On Wed, Oct 08, 2003 at 05:35:23PM +0530, Karthik Murthy wrote:
> I do have a facility by which I can find out
> the length of the ogg file. If the length of the
> file is know how can the play time be computed..
> Of course the play time should be computed
> using just the length of the audio data and not the headers.
> How can this be dome..
Two options:
The vorbis file itself has a 'nominal bitrate' field
(vorbis_info.bitrate_nominal for normal VBR streams and/or
vorbis_info.bitrate_upper and .bitrate_lower for constrained streams.
See the comments in the structure definition in vorbis/codec.h for
details. However, these aren't guaranteed to be accurate or even set, so
you should sanity check them.
A better approach is to estimate the length based on the measured
bitrate. Divide the elapsed playback time by the number of bytes fed to
the decoder so far and multiply that by the known total size of the
file. This will obviously fluctuate a bit at the beginning, but should
be reasonably accurate for most streams. (it will miss digital silence
at the end of files though)
Hope that helps,
-r
--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-dev-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis-dev
mailing list