keiusui has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I am trying to write a script that re-encodes an mp3 file from one bitrate to another bitrate and saves the resulting mp3 into a different directory.

For example, let's say "song.mp3" is located in the "audio" directory and is encoded at 256 kbps. I am trying to write a Perl script that converts "song.mp3" into 64 kbps and saves the new file into the "preview" directory. The original "song.mp3" file should remain unedited.

Does anyone have any idea how I would get started? Thank you so much for any help you might be able to provide.

Replies are listed 'Best First'.
Re: re-encode mp3 files
by targetsmart (Curate) on May 21, 2009 at 06:43 UTC
    lame will help you
    or try audacity
    these are the tools that I generally use.

    Vivek
    -- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.
Re: re-encode mp3 files
by Anonymous Monk on May 21, 2009 at 06:37 UTC
Re: re-encode mp3 files
by bart (Canon) on May 21, 2009 at 13:33 UTC
    There's an Apache module on CPAN, by Lincoln Stein, that can do that on the fly: Apache::MP3. It depends on an external mp3 decoder and encoder... i believe LAME. You could check it out for inspiration.
Re: re-encode mp3 files
by Corion (Patriarch) on May 24, 2009 at 16:12 UTC

    In addition to what you've got already, take a look at Ffmpeg and just calling the ffmpeg executable from within Perl.

      Thank you so much for this. Installing ffmpeg and calling it from the command line turned out to be the easiest solution.