tags:

views:

1244

answers:

3

Hello folks,

Currently im working on some sort of music project, so dealing with user mp3 uploads. And the problem is that i cant find id3 library, that will work correctly for all files. I have tried libs: id3-ruby, Mp3Info, but still none of them gives me correct results. For example, most common problems:

  • wrong stream parameters (bitrate and sample rate, sometimes duration)
  • not supported extended tags

So, i decided to add form, so users have to fill optional information like Artist and title, that helped a little, but didnt solve the problem.

Does anyone knows most usable and powerful library for ruby that will work with ID3 correctly?

+1  A: 

http://www.hakubi.us/ruby-taglib/

I used this for a project and it worked quite well. Wrapper around taglib, which is very portable.

Paul Betts
thanks, i`ll try it. does it have any problems ?
Dan Sosedoff
I used it against my entire MP3 library and didn't have any problems with it. I didn't do anything with bitrate/sample rate though, so I can't speak to that.
Paul Betts
+1  A: 

http://id3lib-ruby.rubyforge.org/

I particularly liked this one, you can also write tags to the file.

Garrett
yes, but sometimes this lib doesnt work correct, so i decided to switch to something better
Dan Sosedoff
Looks like it doesn't support utf-8. Otherwise it is neat.
ragu.pattabi
+2  A: 

I've used this:

http://ruby-mp3info.rubyforge.org/

or

gem install ruby-mp3info (add the regulation sudo for Mac or *nix)

There's some rdoc documentation, which is nice. On the downside, I don't much like the use of upper-case field names, which seems too concerned to preserve the names from the spec. Maybe I should hack in some aliases. Anyway, this sample script scans my music library and counts words in titles:

require 'mp3info'

count = 0
words = Hash.new { |h, k| h[k] = 0 }
Dir.glob("E:/MUSIC/**/*.mp3") do |f|
  count += 1
  Mp3Info.open(f) do |mp3info|
    title = mp3info.tag2.TIT2
    next unless title
    title.split(/\s/).each { |w| words[w.downcase] += 1 }
  end
end
puts "Examined #{count} files"
words.to_a.sort{ |a, b| b[1] <=> a[1] }[0,100].each { |w| puts "#{w[0]}: #{w[1]}" }
Mike Woodhouse
Thanks for the suggestion. But the interface looks so difficult. I would like something like what id3lib-ruby gives. e.g.tag = ID3Lib::Tag.new('test.mp3')tag.title #test_titletag.title = 'new_title'tag.udpate! #test.mp3's title is updated with new_title
ragu.pattabi