• Skip to main content

Itchy Fish

Perl Audio Converter – Convert Between Dozens of Audio Formats

by itchyfish

I download a lot of music. In fact, for the past few years, it’s been a rare event for me to purchase a physical CD instead of purchasing downloadable music from iTunes, Amazon, 7Digital, Lala (before Apple bought it), or other online stores. If there’s no other choice, I’ll purchase MP3 files as long as they’re cheap enough, but if I have my way, I’ll purchase a lossless format, such as FLAC.

What’s the difference? If you take the music on a CD and copy it directly to your computer’s hard drive, you’ll have a WAV or AIFF file (depending on whether you’re using Windows or Mac OSX or Linux). Regardless, what you have is the music off the CD in it’s purest form, the full wave without any compression. The music will sound exactly the same as the CD, and if you burn those files back to CD, it should be identical to the original. The problem is that although the sound is excellent, the size is awful for portable devices. A 60-minute CD, saved as WAV files, will be roughly 600 MB. If you transferred those to your 8 GB iPod Nano, you’ll likely only be able to fit about 14 albums, or maybe 150 songs. Not a whole lot. So the size is an impediment.

If you convert that same 60-minute CD to MP3 files, you gain a whole lot of space. Most online stores sell MP3 files encoded at 256 kbps, which is just a designation that tells how many bits of information are included each second. At this rate (compared to 1411 kbps for a CD), your files are suddenly only about 20 percent of their original size. Depending on how you use your portable player, you could encode at 128 kbps (before hard drives got cheaper, this used to be the “standard” bitrate), and then each file would be a tenth the size of the original. The drawback, of course, is that by removing so much information (hence the term “lossy” for MP3 and other similar formats), you do affect the sound quality. Maybe it isn’t affected a lot, and maybe you or I don’t hear as big a difference at higher bitrates, but the loss is still there.

So if I have a choice, I’ll buy the FLAC, as I mentioned, which is a lossless format. It’s smaller than a WAV or AIFF file (by 30-60 percent, depending on the type of music), but if it’s burned to CD, the resulting disc is identical to the original, something that can’t be said when MP3 files are burned to CD.

Still, FLAC and other lossless formats are kind of big for a portable player, at least for me, so I still need to encode them to MP3 for uploading to my MP3 player. There are some good programs for Linux for just this purpose, Sound Converter, GNAC and SoundKonverter to name three. But sometimes I just like to open a terminal and type in a few commands and have the job started that quickly.

Enter a program called Perl Audio Converter. A commandline tool, Perl Audio Converter is a simple way to not only convert from FLAC to WAV, WAV to MP3 or WAV to FLAC, but to and from dozens of different formats. So if you have Windows Media Audio files that you want to put on your iPod, no problem. If you downloaded some Real Audio files years ago and want them burned to CD, again: no problem. In fact, depending on whether or not you have the correct libraries installed, you should have all the converting power you need. I just took a quick peek, and I have 70 formats I can read, and 49 I can encode to, all with one quick and easy command.

How quick and easy? Very. Let’s say I want to use Perl Audio Convert (activated by typing “pacpl”) to convert a folder full of FLAC files to MP3. Once I navigate to the folder, I would simply type the following:

pacpl -t mp3 *.flac

That’s it! Here’s what that all means:

“pacpl” – this is what starts the Perl Audio Converter
“-t” – what follows this will be the format we’ll be encoding to
“mp3” – in this example, we’re encoding to MP3 format
“*.flac” – this says that we should encode to MP3 any file that ends with “.flac”

It really is that simple. Of course, it can get more detailed. The default bitrate for MP3 files is 128 kbps. I usually like mine encoded at twice the bitrate (256 kbps). To accomplish that, I would type exactly the same thing, except I would add one argument, as such:

pacpl -t mp3 -bitrate 256 *.flac

As you can probably guess, the “-bitrate 256” argument tells the Perl Audio Converter that I want my MP3 encoded at 256 kbps.

There’s a lot more you can do with Perl Audio Converter. You can encode from one format to another, but instead of the newly encoded files being in the same folder as the originals, you can save them somewhere else. Using the same example, you would add an extra argument to the end, to finish with the following command:

pacpl -t mp3 -bitrate 256 *.flac -outdir /new/path/for/mp3/files

You can obviously name the new folder whatever you want! One word of warning, however. The folder must already exist in order for Perl Audio Converter to place your new files in it. It is unable to create the folder on its own.

One more. If you have folders within folders, all containing files you’d like to encode, Perl Audio Converter can move through those folders recursively, encoding as it goes. You can also, in this case, have Perl Audio Converter keep the same directory structure, so you’re left with two identical directories, one with your untouched originals and one with your new files. The command in this case would similar to the following:

pacpl -t mp3 -bitrate 256 -r -p /music/ -outdir /new music/

In this command, I am telling Perl Audio Converter to convert everything within my “music” folder to MP3 with a bitrate of 256 kbps. The “-r” stands for recursive, meaning it will continue drilling down level by level, converting all files it sees. The “-p” means to preserve the existing directory structure, which should be placed in a folder (that already exists), called “new music” in this case.

Perl Audio Converter is a really powerful tool. It has a relatively simple syntax to understand, and can do infinitely more than I’ve touched on here. If your files have proper tags, and the format supports it, Perl Audio Converter can transfer the tags over, so you aren’t left with freshly encoded music that appears to your MP3 player to have no track information. You can, assuming you have a folder filled with both Windows Media and MP3, choose to only convert the Windows Media files. You can delete your original files once the encoding is done, or you can perform batch manipulation tasks, such as normalizing the WAV file before encoding (so the loud point of all your songs is the same volume, as you experience when listening to the radio), or you can change the sampling rate, the number of channels, and more.

Perl Audio Converter is strictly used via the commandline, so you’ll either have to get comfortable typing or have a cheat sheet ready so you can copy and paste in your commands. It may seem a bit daunting at first, but once you get the hang of it, I think you’ll find, as I did, that converting audio files this way is a lot more efficient than using a converting program where you have to individually select the files you want to convert, then check buttons and select options from pull-down menus to choose your settings. Sure, it might be a bit of a geeky tool, but it’s fast, efficient, and really not that hard to use. What more could you want? Perl Audio Converter is available for Linux, Windows and Mac OS X.

http://pacpl.sourceforge.net/

Related

  • Perl and Bioinformatics: First Perl Program Tutorial
  • How to Convert Video for Free Using Any Video Converter
  • School Bus Crash Kills 2, Injures Dozens in Gray Summit, Missouri
  • Perl and Bioinformatics: Storing DNA and RNA Strands
  • Product Review: 220 Electronics Step Up & Down Voltage Converter DS-1000
  • Measures - Unit and Currency Converter for iPhone
Previous Post: « We Two: a Biography of Queen Victoria and Prince Albert
Next Post: The Mountain Gateway Museum; A Historic Attraction in Old Fort North Carolina »

© 2021 Itchy Fish · Contact · Privacy