隽 徐
2009-Apr-08 09:35 UTC
[Vorbis-dev] How can I get the precise play time of the ogg vorbis file?
Hi all, ? I have a?question about the ogg vorbis decoder.?As far as I know, there are?three?vorbis headers -- ID, Comment and Codebook. And in?ID header, I can get the sample rate, maximum bitrate, nominal bitrate and minimum bitrate. Now, I want to get the play time of the file, so I use the file length to divide the nominal bitrate, and get the play time, but it is always shorter than the real time. So I want to know how to get the precise play time of the ogg vorbis file? ? By the way, why many files don't set the maximum bitrate and minimum bitrate? ? Thank you?very much. ? Susan ___________________________________________________________ ????????????????? http://card.mail.cn.yahoo.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.xiph.org/pipermail/vorbis-dev/attachments/20090408/de3c1bdd/attachment.htm
ogg.k.ogg.k at googlemail.com
2009-Apr-08 10:00 UTC
[Vorbis-dev] How can I get the precise play time of the ogg vorbis file?
> bitrate. Now, I want to get the play time of the file, so I use the file > length to divide the nominal bitrate, and get the play time, but it is > always shorter than the real time. So I want to know how to get the preciseSince the data is compressed, there will be less bits than for a raw PCM stream with which such a method would work. There's the Ogg encapsulation that you'd need to remove too anyway. If you use libvorbisfile, there's an API to get the exact length. If not, you need to get the granpos of the first packet, and that of the last one, and substract, then scale by the sampling rate (not the bitrate). I believe you'd have to add the number of samples in the very first packet too, but I recall someone saying no, though I did not understand the reason.> By the way, why many files don't set the maximum bitrate and minimum > bitrate?I believe these are only set for managed mode, but I may be wrong. In any case, those values are only indicative AFAIK.