[vorbis-dev] getting playback length from ogg vorbis file
Lourens Veen
lourens at rainbowdesert.net
Fri Jul 11 03:39:29 PDT 2003
On Fri 11 July 2003 12:31, Lourens Veen wrote:
> On Fri 11 July 2003 12:06, Jack Angel wrote:
> > On Thu, 10 Jul 2003 17:39:36 -0600
> >
> > Jack Moffitt <jack at xiph.org> wrote:
> > > > I need to extract playback length from ogg vorbis file,
> > > > with 1/100th second precision. The ogginfo program tells
> > > > the playback length to 1 second precision. Why not to
> > > > change ogginfo? I suppose many automatic tools need
> > > > precision higher than 1 second.
> > >
> > > I think changing ogginfo is reaosnable.
> >
> > I think so too, because ogg123 reports play time / current time
> > to 1/100th second precision. Ogginfo should too. I need it
> > because I want to do queries to cddb based on several ogg
> > vorbis tracks, and cddb has got resolution of 75 cd frames per
> > second - for it to work, i've got know ogg length to pretty
> > high res. Will somebody do this, or maybe I've got to do it
> > myself (if I figure the sources ;)?.
>
> How is this patch (against ogginfo2.c in vorbis-tools-1.0):
Hold on, that seems to give incorrect results. There is something
fishy there with the floor() construction. This seems to work
better:
--- ogginfo2.c.old Fri Jul 11 12:16:04 2003
+++ ogginfo2.c Fri Jul 11 12:36:41 2003
@@ -373,19 +373,20 @@
static void vorbis_end(stream_processor *stream)
{
misc_vorbis_info *inf = stream->data;
- long minutes, seconds;
+ long minutes, seconds, seconds100;
double bitrate, time;
time = (double)inf->lastgranulepos / inf->vi.rate;
minutes = (long)time / 60;
seconds = (long)time - minutes*60;
+ seconds100 = (long)((time - minutes*60 - seconds)*100.0);
bitrate = inf->bytes*8 / time / 1000.0;
info(_("Vorbis stream %d:\n"
"\tTotal data length: %ld bytes\n"
- "\tPlayback length: %ldm:%02lds\n"
+ "\tPlayback length: %ldm:%02lds.%02ld\n"
"\tAverage bitrate: %f kbps\n"),
- stream->num,inf->bytes, minutes, seconds, bitrate);
+ stream->num,inf->bytes, minutes, seconds, seconds100,
bitrate);
vorbis_comment_clear(&inf->vc);
vorbis_info_clear(&inf->vi);
<p>Also, I understand why this works :-). But I still don't see why
(long)((time - floor(time) * 100.0) doesn't work...
Lourens
--
GPG public key: http://home.student.utwente.nl/l.e.veen/lourens.key
--- >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