ruby-mp3info read low-level informations and manipulate tags on mp3 files.
Ruby Python
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
fusil adding fusil fuzzer tests Mar 10, 2009
lib prepared for v0.8.10 Oct 31, 2016
test prepared for 0.8.9 Feb 2, 2016
.hgtags Added tag v0.8.4 for changeset 510c84517921 Apr 26, 2014
.travis.yml yl - Fix CI link and make test pass Sep 17, 2014
History.txt prepared for v0.8.10 Oct 31, 2016
Manifest.txt add missing fixtures.yml to gem Dec 5, 2013
ruby-mp3info.gemspec prepared for v0.8.10 Oct 31, 2016


Build Status


ruby-mp3info read low-level informations and manipulate tags on mp3 files.


  • Written in pure ruby
  • Read low-level informations like bitrate, length, samplerate, etc...
  • Read, write, remove id3v1 and id3v2 tags
  • Correctly read VBR files (with or without Xing header)
  • Only 2.3 version is supported for writings id3v2 tags
  • id3v2 tags are always written in UTF-16 encoding


require "mp3info"

# Read and display infos & tags"myfile.mp3") do |mp3info|
  puts mp3info

# read/write tag1 and tag2 with Mp3Info#tag attribute
# when reading tag2 have priority over tag1
# when writing, each tag is written."myfile.mp3") do |mp3|
  puts mp3.tag.title
  puts mp3.tag.artist
  puts mp3.tag.album
  puts mp3.tag.tracknum
  mp3.tag.title = "track title"
  mp3.tag.artist = "artist name"

# tags are written when calling Mp3Info#close or at the end of the #open block

### access id3v2 tags"myfile.mp3") do |mp3|
  # you can access four letter v2 tags like this
  puts mp3.tag2.TIT2
  mp3.tag2.TIT2 = "new TIT2"
  # or like that
  # at this time, only COMM tag is processed after reading and before writing
  # according to ID3v2#options hash
  mp3.tag2.options[:lang] = "FRE"
  mp3.tag2.COMM = "my comment in french, correctly handled when reading and writing"

### image manipulation

file ='input_img','rb') '1.mp3' do |m|
   pictures = # array of images :
   pictures.each do |description, data|
      # description ends with (.jpg / .png) for easy writing to file
      File.binwrite(description, data)
  m.tag2.remove_pictures # remove all images

  m.tag2.add_picture( # add a single image to APIC tag
  # **optionally**, you may include options for the image tag to add_picture():
  # options = { mime: 'jpeg|gif|png', description: "description",
  #             pic_type: 0 }
  # There is no need to specify mime or options because the mime is guessed based on the input image
  # Only one image is permitted in the mp3 for compatibility. add_picture() overwrites all previous images.
  # Please note:
  # If supplying :mime option just supply the mime 'jpeg', 'gif' or 'png', the code adds the "image/.." for you!
  # e.g. m.tag2.add_picture(, mime: 'jpeg', pic_type: 3) gets a mime "image/jpeg"


  • iconv when using ruby 1.8


gem install ruby-mp3info


After checking out the source, run:

$ rake newb

This task will install any missing dependencies, run the tests/specs, and generate the RDoc.




  • encoder detection
  • support for more tags in id3v2
  • generalize id3v2 with other audio formats (APE, MPC, OGG, etc...)