Honey, I Shrunk The MP3s!
March 25, 2009 6:28 PM

Any good libraries for transcoding audio, preferably with a Ruby API? I'm thinking "like ImageMagick, but for audio files."

I'm working on a project for the iPhone and iPod Touch (will announce on Projects when it gets approved) that involves the use of MP3 files. For my purposes, I don't need high-quality content - in fact, it'd be better if I could reduce the size of the files in question.

I've written a Ruby on Rails web application to support the iPhone app. Currently it stores MP3s as blobs in the database. I'd like to transcode the MP3s within the Rails app.

My preferred solution would be to have some Ruby code that looked kind of like the following:
def transcoded_audio # returns data for transcoded MP3
  original_audio = AudioFile.new(content_blob)
  original_audio.transcode(:format => 'mp3', :bitrate => 65536) unless original_audio.bitrate <= 65536
end

I've got a funny feeling that I'll have to screw around directly with LAME, but if there's something out there that wraps it nicely, I'd really like to know about it!
posted by lowlife to Computers & Internet (4 answers total) 1 user marked this as a favorite
Sox is a lot like ImageMagick for audio files. Can't help with the Ruby wrapper though.
posted by flabdablet's sock puppet at 6:44 PM on March 25, 2009


+1 for SoX- "the Swiss Army knife of sound processing programs". You do know that transcoding mp3 to mp3 (or any lossy to lossy format for that matter) is a BAD thing though, right?
posted by dirm at 8:57 PM on March 25, 2009


As to the ruby part, this might be what you want.

Screwing around with lame really isn't that scary - coding C with Michael Hipp's mpglib is scarier. Still, sox is about as swiss-army an audio product as you're going to get.
posted by eclectist at 12:13 AM on March 26, 2009


@dirm, I recognize that there's going to be a loss of quality, but for the purposes of my app that quality doesn't need to be fantastic, just "acceptable". Playback is going to be through the external speaker.

SoX looks very cool... will dig a little deeper into that.
posted by lowlife at 6:24 AM on March 26, 2009


« Older I'm a 35 yr old single male with no ties to anyone...   |   Why don't I sweat? Newer »
This thread is closed to new comments.