Decode MP3s with Ruby 1

Posted by Aaron Patterson on September 21, 2007

Here is an example of decoding mp3s using ruby. First make sure to install icanhasaudio. It should just be a "gem install icanhasaudio". Here is the code:

require 'rubygems'
require 'icanhasaudio'

reader = Audio::MPEG::Decoder.new
reader.decode(File.open(ARGV[0], 'rb'), $stdout)

icanhasaudio just takes two IO streams, an input and an output. In our case the input is the file provided on the command line, and the output is STDOUT. To use the script, simply do:

$ ruby decoder.rb phil_collins.mp3 > phil_collins.wav
Trackbacks

Use this link to trackback from your own site.

Comments

Leave a response

  1. jax Tue, 02 Oct 2007 19:40:13 PDT

    su su sudeo energy drink!

Comments

Check Spelling
Activate Spell Check while Typing