ruby-mp3info gem

Posted by greg Sun, 28 Sep 2008 04:18:00 GMT

While working on the first rev of isfuckingawesome.me I needed some code to help me read the duration of an mp3 file. I came across ruby-mp3info and decided to use it. This little nugget of a library reads all the id3 info baked into your audio files. My design was simple (or so I thought): serialize the mp3info object for each post saved with an audio file.

Everything was working fine until that one user decided to upload too large of a file. The webserver upload threshold is set to 50MB. This is pretty large and I know I tested it locally uploading at least a couple of different 40MB+ files without discovering this problem. I’m not surprised because that’s usually how it works.

It turns out the mp3info object stores the binary blob in the db when serialized. And what do you know? MySQL has a a defalult upper limit on how much data is allowed per column. And what do you know, again? MySQL chokes if the size of the binary text exceeds the limit of the column. Whoops :) I can adjust this but I’m not going to futz around with default column limit right now.

Without monkey patching (which isn’t really something I want to spend an elaborate amount of time on), it doesn’t appear removing the blob before writing to the DB is an option. So, I’m going to cut my loses on this one and only save the values I really need access to (duration) and nothing else (like genres, title, track, etc). Sometimes, you need to know when to fold them. My gambling is done.

Rev 2 coming in the next few days…

Comments

Leave a response

Comments