Forums | Admin

Discussion Forums: open-discussion

Start New Thread Start New Thread

 

By: Scott Bronson
Patch 1 [ reply ]  
2005-04-21 17:43
If a file is VBR without a Xing header, mp3info crashes:

/usr/lib/ruby/1.8/mp3info.rb:370:in `initialize': undefined method `/' for nil:NilClass (NoMethodError)
from ./test:158:in `new'
from ./test:158:in `open'
from ./test:299:in `process'
from ./test:320
from ./test:315:in `find'
from /usr/lib/ruby/1.8/find.rb:38:in `catch'
from /usr/lib/ruby/1.8/find.rb:38:in `find'
from ./test:315

This patch fixes it. The displayed bitrate is wrong, of course, but without the Xing header afaict there's no way to calculate it without doing a linear scan over the entire file...

--- mp3info.rb.orig 2005-04-21 09:57:34.000000000 -0700
+++ mp3info.rb 2005-04-21 10:25:05.000000000 -0700
@@ -367,7 +367,9 @@
end
if @vbr
@length = (26/1000.0)*@frames
- @bitrate = (((@streamsize/@frames)*@samplerate)/144) >> 10
+ if @streamsize
+ @bitrate = (((@streamsize/@frames)*@samplerate)/144) >> 10
+ end
else
# for cbr, calculate duration with the given bitrate
@streamsize = @file.stat.size - (@hastag1 ? TAGSIZE : 0) - (@hastag2 ? @tag2["length"] : 0)