From: Konrad Meyer Date: 2007-12-15T11:02:11+09:00 Subject: Re: Work with Audio Files --nextPart4219988.Q269TXoMRe Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Quoth John Joyce: >=20 > On Dec 14, 2007, at 7:12 PM, Konrad Meyer wrote: >=20 > > Quoth Petr Kout: > >> Lloyd Linklater wrote: > >>> Petr Kout wrote: > >>>> Hi, > >>>> > >>>> I am new to Ruby on Rails and I consider converting my application > >>>> written in Java into Ruby. The question is, however, is there =20 > >>>> any plugin > >>>> or other way to handle MP3 and other audio files? I need to Ruby =20 > >>>> to be > >>>> able to tell me how long the uploaded MP3 is and ideally, give =20 > >>>> me the > >>>> possibility to cut the file on the server if it's too long. I =20 > >>>> looked all > >>>> over Google, nothing found. Thank you very much for any advice. > >>> > >>> http://www.ruby-forum.com/topic/130804#new > >> > >> Hi, > >> > >> 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 =20 > >> 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 =20 > >> do. > >> > >> Thanks. > >> > >> Peter > > > > There is a great library out in the wild called "metadata" that you =20 > > can use to > > get information about mp3s (as well as many other filetypes) that I =20 > > think is > > available in gem form. You might take a look at that. > > > > If you want to truncate a constant bitrate mp3, AFAIK they are =20 > > structured such > > that you *could* crudely lop off some bytes from the end (channels * > > time_to_clip * bitrate bytes). If not, you'll need to use some sort of > > external mp3 library. I don't know of any that exist with ruby =20 > > bindings. You > > might look at LAME though I'm not sure how much that will do. > > > > HTH, > > --=20 > > Konrad Meyer http://konrad.sobertillnoon.com/ > Remember, keyword there was CONSTANT bitrate, variable bitrate might =20 > give you more trouble doing that without more care. > Be sure any meta data matches changes or some apps might complain =20 > about the audio file. Well, no, mp3 is made such that it can be streamed over the internet. Apps= =20 should behave nicely even if the stream ends before they expect it. Variabl= e=20 bitrate will not work, of course. Better use a tool. (Note "crudely" in the= =20 original email.) Regards, =2D-=20 Konrad Meyer http://konrad.sobertillnoon.com/ --nextPart4219988.Q269TXoMRe 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) iD8DBQBHYzWnCHB0oCiR2cwRAlHWAJ9quKctgcZPqdwZbpBaPM15xyYmSQCfV8pr 7J64NbayIA/bHeorbWVepj8= =rK5e -----END PGP SIGNATURE----- --nextPart4219988.Q269TXoMRe--