Rubing mp3 id3 parsing

I am currently working on a music project that uploads custom mp3 files. The problem is that I can not find the id3 library that will work correctly for all files. I tried id3-ruby and Mp3Info libs, but none of them give me consistently correct results. For example, the most common problems:

  • incorrect flow parameters (baud rate and sampling rate, sometimes duration)
  • does not support extended tags

I decided to add a form in which users can provide additional information, such as Artist and title; which helped a little, but did not completely solve the problem.

What is the most convenient and powerful ID3 library for ruby?

+9
ruby mp3 id3
source share
5 answers

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

I used this for a project and it worked quite well. Wrap around a taglib that is very portable.

+6
source share

I used this:

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

or

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

There is some rdoc documentation, which is nice. On the other hand, I don't really like the use of uppercase field names, which seem to be too worried about keeping names from the specification. Maybe I should hack some aliases. Anyway, this sample script scans my music library and counts the words in the headers:

 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]}" } 
+4
source share

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

I especially liked this, you can also write tags to a file.

0
source share

id3tag is another option. Example:

 require "id3tag" mp3_file = File.open('/path/to/your/favorite_song.mp3', "rb") tag = ID3Tag.read(mp3_file) puts "#{tag.artist} - #{tag.title}" 
0
source share

As of 2019, the best answers are:

All other libraries have not been supported for a long time.

Distinctive features of the ID3Tag by Christs Ozols

  • only for reading
  • Can read tags v1.x, v2.2.x, v2.3.x, v2.4.x
  • Supports UTF-8, UTF-16, UTF-16BE and ISO8859-1 encoding
  • last update July 2018
  • Pure Ruby

Moumar ruby-mp3info features

  • read and write
  • Only version 2.3 is supported for writing id3v2 tags
  • Id3v2 tags are always UTF-16 encoded
  • last update in April 2017
  • Pure Ruby

hallmarks of taglib-ruby

  • read and write
  • Many formats, not just Mp3
  • Read / write ID3v1 and ID3v2, including ID3v2.4 and Unicode
  • last updated May 2018
  • Linking a Well-Supported C ++ Library
0
source share

All Articles