From: Konrad Meyer Date: 2007-12-15T10:12:39+09:00 Subject: Re: Work with Audio Files --nextPart3487176.FzjzyvuKxp Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Quoth Petr Kout: > Lloyd Linklater wrote: > > Petr Kout wrote: > >> Hi, > >>=20 > >> I am new to Ruby on Rails and I consider converting my application > >> written in Java into Ruby. The question is, however, is there any plug= in > >> or other way to handle MP3 and other audio files? I need to Ruby to be > >> able to tell me how long the uploaded MP3 is and ideally, give me the > >> possibility to cut the file on the server if it's too long. I looked a= ll > >> over Google, nothing found. Thank you very much for any advice. > >=20 > > http://www.ruby-forum.com/topic/130804#new >=20 > Hi, >=20 > thank you for the link, but it's not what I was looking for. I do not > need to play the mp3 file. I need to be able to analyze it on the > backend; that is, to get its length in seconds, and possibly truncate it > (not necessary). I was doing it in Java so far. If I can't do this on > the backend, I can't switch to Ruby, which is what I would love to do. >=20 > Thanks. >=20 > Peter There is a great library out in the wild called "metadata" that you can use= to=20 get information about mp3s (as well as many other filetypes) that I think i= s=20 available in gem form. You might take a look at that. If you want to truncate a constant bitrate mp3, AFAIK they are structured s= uch=20 that you *could* crudely lop off some bytes from the end (channels *=20 time_to_clip * bitrate bytes). If not, you'll need to use some sort of=20 external mp3 library. I don't know of any that exist with ruby bindings. Yo= u=20 might look at LAME though I'm not sure how much that will do. HTH, =2D-=20 Konrad Meyer http://konrad.sobertillnoon.com/ --nextPart3487176.FzjzyvuKxp Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQBHYyn9CHB0oCiR2cwRAo0AAKCzjcLHNKC1FSzNTtG9YGF4JlJROACgnl8f KAZJttlNdmK7J0L9efiJwM4= =XWcK -----END PGP SIGNATURE----- --nextPart3487176.FzjzyvuKxp--