Page 1 of 1

VLC displays wrong duration (length) of vorbis file

Posted: 08 May 2007 10:49
by MartinT
Is there any chance to display right duration(length) info of vorbis file? Winamp has no problem with this, so i think it must use some other information to display right lengt of file.

Posted: 08 May 2007 11:07
by DJ
In a 3:30 tune I'm seeing about a 1 second variance between various players including VLC. What are you seeing?

Posted: 08 May 2007 14:32
by MartinT
I see different variance e. g. 2:34 song looks in VLC like 2:41 song. Other 1:22 song looks in VLC like 1:02 song atc. So differences are more than 1s in both directions.

Playback is without problems but at the end of song status bar looks like: 1:22/1:02.

EDIT:
I think VLC uses wrong algorithm to calculate vorbis length.
e. g.
file size: 753924B
average bitrate: 72kbps = 9kBps
nominal bitrate: 96kbps = 12kBps
753924/1024 = 736,254kB/9 = 81,806s = 1:21,806 (right value)
753924/1024 = 736,254kB/12 = 61,356 = 1:01,345 (bad value)

Posted: 08 May 2007 18:23
by Jean-Baptiste Kempf
I see different variance e. g. 2:34 song looks in VLC like 2:41 song. Other 1:22 song looks in VLC like 1:02 song atc. So differences are more than 1s in both directions.

Playback is without problems but at the end of song status bar looks like: 1:22/1:02.

EDIT:
I think VLC uses wrong algorithm to calculate vorbis length.
e. g.
file size: 753924B
average bitrate: 72kbps = 9kBps
nominal bitrate: 96kbps = 12kBps
753924/1024 = 736,254kB/9 = 81,806s = 1:21,806 (right value)
753924/1024 = 736,254kB/12 = 61,356 = 1:01,345 (bad value)
Hmmm... Are you able to found where the bug is ?
Are some bitrates correct ?

Posted: 08 May 2007 19:14
by DJ
The bit rate of the file I just tried is 255 kb/s, with a file size of 6574025 and it is showing total time of 3:25 if that's helpful.

Posted: 08 May 2007 19:24
by MartinT
I don`t know. I dont`t like code reading. But i found this API documentation for developers: http://www.xiph.org/vorbis/doc/vorbisfile/fileinfo.html So information about average bitrate or total length of vorbis file is available via this functions.
EDIT: Maybe algorithm use nominal bitrate instead of average bitrate to calculate vorbis length.

Posted: 08 May 2007 19:34
by MartinT
The bit rate of the file I just tried is 255 kb/s, with a file size of 6574025 and it is showing total time of 3:25 if that's helpful.
255 nominal or average? nominal != average

Right length for 255kb/s average bit rate is 3:21,41.

Posted: 09 May 2007 08:10
by DJ
Vorbis is always VBR as it can't be made to be CBR. The bitrate quoted is what is reported in VLC and I have always assumed this to be ABR. MPC says this same file is 3:26. This is using the Haali front end for OGG/OGM and CoreVorbis.

Posted: 09 May 2007 10:20
by Jean-Baptiste Kempf

Posted: 09 May 2007 18:30
by MartinT
Vorbis is always VBR as it can't be made to be CBR. The bitrate quoted is what is reported in VLC and I have always assumed this to be ABR. MPC says this same file is 3:26. This is using the Haali front end for OGG/OGM and CoreVorbis.
I know, that vorbis is always VBR. Nominal bitrate specifies approximate quality. So final audio file will have ABR approximately as nominal. Sometimes higher, sometimes lower. So if you calculate song lengt nominal bitrate is irrelevant.

But in VLC is displayed only nominal bitrate. As i showed in calculation above.

Posted: 09 May 2007 18:31
by MartinT
I think that i found problem in source code, but i`m not so good in C programming to fix it.

possibly here is explanation:
http://www.xiph.org/vorbis/doc/vorbisfile/fileinfo.html
VLC uses function "ov_info()" to get "vorbis_info" structure that contains nominal bitrate info in variable "bitrate_nominal"
But there is also function "ov_bitrate()" that returns average bitrate or
function "ov_time_total()" that returns total time length in seconds of a physical or logical seekable bitstream.