Work with Audio Files

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 any plugin
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 all
over Google, nothing found. Thank you very much for any advice.

···

--
Posted via http://www.ruby-forum.com/\.

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 any plugin
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 all
over Google, nothing found. Thank you very much for any advice.

Play a Music File - Ruby - Ruby-Forum

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 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.

Thanks.

Peter

···

--
Posted via http://www.ruby-forum.com/\.

just dig through the gems.
there should be something that deals with id3 tags at the very minimum.
much of the info should really just be part of the file format anyway.
Implementing your own solution should be easy in Ruby, and a great way to improve your Ruby.
I just googled this string
ruby audio files gem

plenty of stuff there to get you started.

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 any plugin
>> 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 all
>> over Google, nothing found. Thank you very much for any advice.
>
> Play a Music File - Ruby - Ruby-Forum

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 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.

Thanks.

Peter

There is a great library out in the wild called "metadata" that you can use to
get information about mp3s (as well as many other filetypes) that I 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 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 bindings. You
might look at LAME though I'm not sure how much that will do.

HTH,

···

--
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertillnoon.com/

John Joyce wrote:

just dig through the gems.
there should be something that deals with id3 tags at the very minimum.
much of the info should really just be part of the file format anyway.
Implementing your own solution should be easy in Ruby, and a great
way to improve your Ruby.
I just googled this string
ruby audio files gem

plenty of stuff there to get you started.

Thank you John,

I will look into the Google search based on your keywords. I did not
exactly know how to put this into Google. The word gem is probably
important 'cause I didn't get the same results as you did before.

Thank you again.

Peter

···

--
Posted via http://www.ruby-forum.com/\.

Konrad Meyer wrote:

Quoth Petr Kout:

>
Thanks.

Peter

There is a great library out in the wild called "metadata" that you can
use to
get information about mp3s (as well as many other filetypes) that I
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
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 bindings.
You
might look at LAME though I'm not sure how much that will do.

HTH,

Okay Konrad, thanks very much! That sounds interesting. I will
definitely look into it. I was thinking that for cutting the mp3, I
might look for some other technology, such as a command line tool for
Linux and run it from inside Ruby on Rails. The metadata library sounds
like exactly what I need. I also need a library to crop pictures, but I
assume that that one should be much easier to find.

Thanks again.

Peter

···

--
Posted via http://www.ruby-forum.com/\.

Remember, keyword there was CONSTANT bitrate, variable bitrate might give you more trouble doing that without more care.
Be sure any meta data matches changes or some apps might complain about the audio file.

···

On Dec 14, 2007, at 7:12 PM, Konrad Meyer wrote:

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 any plugin
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 all
over Google, nothing found. Thank you very much for any advice.

Play a Music File - Ruby - Ruby-Forum

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 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.

Thanks.

Peter

There is a great library out in the wild called "metadata" that you can use to
get information about mp3s (as well as many other filetypes) that I 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 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 bindings. You
might look at LAME though I'm not sure how much that will do.

HTH,
--
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertillnoon.com/

Quoth Petr Kout:

Konrad Meyer wrote:
> Quoth Petr Kout:
>> >
>> Thanks.
>>
>> Peter
>
> There is a great library out in the wild called "metadata" that you can
> use to
> get information about mp3s (as well as many other filetypes) that I
> 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
> 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 bindings.
> You
> might look at LAME though I'm not sure how much that will do.
>
> HTH,

Okay Konrad, thanks very much! That sounds interesting. I will
definitely look into it. I was thinking that for cutting the mp3, I
might look for some other technology, such as a command line tool for
Linux and run it from inside Ruby on Rails. The metadata library sounds
like exactly what I need. I also need a library to crop pictures, but I
assume that that one should be much easier to find.

Thanks again.

Peter

Yeah, I'd recommend using some sort of command-line tool for cutting the mp3.

Regards,

···

--
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertillnoon.com/

Quoth John Joyce:

> 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
>>>> any plugin
>>>> 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 all
>>>> over Google, nothing found. Thank you very much for any advice.
>>>
>>> Play a Music File - Ruby - Ruby-Forum
>>
>> 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
>> 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.
>>
>> Thanks.
>>
>> Peter
>
> There is a great library out in the wild called "metadata" that you
> can use to
> get information about mp3s (as well as many other filetypes) that I
> 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
> 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
> bindings. You
> might look at LAME though I'm not sure how much that will do.
>
> HTH,
> --
> Konrad Meyer <konrad@tylerc.org> http://konrad.sobertillnoon.com/
Remember, keyword there was CONSTANT bitrate, variable bitrate might
give you more trouble doing that without more care.
Be sure any meta data matches changes or some apps might complain
about the audio file.

Well, no, mp3 is made such that it can be streamed over the internet. Apps
should behave nicely even if the stream ends before they expect it. Variable
bitrate will not work, of course. Better use a tool. (Note "crudely" in the
original email.)

Regards,

···

On Dec 14, 2007, at 7:12 PM, Konrad Meyer wrote:

--
Konrad Meyer <konrad@tylerc.org> http://konrad.sobertillnoon.com/

Hey,

There is a useful library ID3Lib that supports reading mp3 tags, and a
ruby wrapper for that library id3lib-ruby that is available as a gem
which I have used to read and modify mp3 files.

Paul

···

On Dec 14, 5:48 pm, John Joyce <dangerwillrobinsondan...@gmail.com> wrote:

On Dec 14, 2007, at 7:12 PM, Konrad Meyer wrote:

> 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
>>>> any plugin
>>>> 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 all
>>>> over Google, nothing found. Thank you very much for any advice.

>>>Play a Music File - Ruby - Ruby-Forum

>> 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
>> 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.

>> Thanks.

>> Peter

> There is a great library out in the wild called "metadata" that you
> can use to
> get information about mp3s (as well as many other filetypes) that I
> 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
> 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
> bindings. You
> might look at LAME though I'm not sure how much that will do.

> HTH,
> --
> Konrad Meyer <kon...@tylerc.org>http://konrad.sobertillnoon.com/

Remember, keyword there was CONSTANT bitrate, variable bitrate might
give you more trouble doing that without more care.
Be sure any meta data matches changes or some apps might complain
about the audio file.

pcrawfor wrote:

···

On Dec 14, 5:48 pm, John Joyce <dangerwillrobinsondan...@gmail.com> > wrote:

>>>> written in Java into Ruby. The question is, however, is there

>> Thanks.
> structured such
Remember, keyword there was CONSTANT bitrate, variable bitrate might
give you more trouble doing that without more care.
Be sure any meta data matches changes or some apps might complain
about the audio file.

Hey,

There is a useful library ID3Lib that supports reading mp3 tags, and a
ruby wrapper for that library id3lib-ruby that is available as a gem
which I have used to read and modify mp3 files.

Paul

Hi Paul,

thank you very much. That sounds like exactly what I am looking for.
Were you also able to use the library to modify variable bitrate mp3s?
Do you have any experience with modifying streaming formats with it?
Such as wma? Thanks a lot!

Peter
--
Posted via http://www.ruby-forum.com/\.