Batch Converting Between Formats?
Yort asks: "With the Christmas season upon us, it's time to dust off the Yuletide music. However, I'm finding once again this year that I'm needing to re-rip all my CDs to fit the format-of-the-year. Ogg Vorbis for my portable, MP3 for the Tivo, WMA and AAC for sharing with co-workers... Argh! So, I've decided it's time to end the madness: Hard drives are cheap, so I'm going to rip all my music once-and-for-all to a lossless format (I'm choosing FLAC at this point), then just batch convert to whatever format I need. I know I'm hardly the first one to think of this, but I've looked around and haven't found much in the way of good OSS tools for this sort of thing. Any recommendations, or do I have to write one myself?"
bash
The unofficial
Just use it as an example to create scripts converting to other formats.
Robert
Bastard Operator From 193.219.28.162
And modify as you see fit - I currently use it for converting movies to xvid with AAC - it works, usually!
perl or python ?
Replies to this post will accept single line or short solutions in the language of your choice which work with the following command line (assuming source and dest dirs already exist and mp3/ogg/flac tools have been installed and in the path):
convert [source directory] [destination directory] [format=mp3/ogg] [bitrate(int)]
You can do what I do these days-- Use the konqueror + kio_audiocd combo. Really smooth. All you have to do is to insert the audio cd and browse it using konquerer ( audiocd:// ) You will actually see an ogg directory. All that is to be done is a simple drag and drop. You wont have to do any scripting. All you have to do is insert your CD and remove it. Redefines the whole ripping experience. I repeat -- Smooth.
Check this out.
Several votes for bash, and a mention of python or perl so far.
Any scripting language will work. Check out freshmeat and sourceforge, there are several scripts available that will access the CDDB and dump the artist/track information.
The only thing missing is a trained monkey to operate the CD drive all day. Better start searching. :)
Is a VFS module for samba called File Ext Map. It takes a share, and a file indicating what conversions to perform, and then converts the files on the fly when called. I haven't got it to work with Samba 3, but in theory, you just set up a share of your flac files, and it would show them as ogg files, for instance.
gstreamer has all the bits, you just need to string it together.
Your portable can play MP3. Your Tivo can play MP3. Your friends can play MP3.
Why not just rip to high-quality MP3 and have done?
My Journal
My audio player knows how to transcode between arbitary formats, amongst plenty of other things. Just select the tracks you want converting, right click, select Convert, select the format, select the destination; if your player doesn't have similar functionality perhaps you should consider finding a better player?
Go to this website:
http://www.hydrogenaudio.org/
(Read and search the site before asking any questions.)
make ogg
make mp3
make wma
make rip
Something alont those lines...I'll leave the Makefile as an excersize for the reader :)
This is the script I use. Wrote it a while back for basically the same reasons -- record everything in FLAC, convert to lossy format of the week. I originally used a bash script but found it to be a bit less than robust and somewhat more difficult to extend.
This script either takes command line args, or, if none present, reads filenames one at a time from the command line. Generally I run it via 'find -name "*.flac" | transcode' and let it DTRT. As an added bonus, it copies the id3 tags from src to dest (assuming id3cp is installed)
http://perl.pattern.net/transcode
I'm needing to re-rip all my CDs to fit the format-of-the-year
Why? Your coworkers are probably going to look at the extension and say "never mind". Yeah yeah yeah, ogg is great, all hail ogg, but when it gets down to it, there's no reason for you to go through all that effort. MP3s play in everything you mentioned. Ogg is going to be a value-add, but down the road. Same with AAC. For the forseeable future, it's all MP3.
"Sometimes a woman is a kind of religion, she can save your soul & set you free from all your sins" - Bad Examples
If you need to write more that about 10-20 lines of bash to make mp3s and oggs out of your flac files, you're doing something wrong.
It is most satisfying to convert 20 albums from flac to ogg and mp3 while you sleep. The old SETI@home score goes down a bit, though :-)
Stick Men
I've been a big fan of jRiver Media Center:
http://www.musicex.com/mediacenter/
I decided to go with Monkey's Audio for my lossless format, just because it integrates with it so well. It's a truely amazing program and one of the best rippers around.
Ripping once to lossless and never doing it again is definitely the way to go.
kiwi
This has nothing to do with changing formats and more to do with you being a flighty user who flits from one music format to another.
MP3 has been around for years and will continue to be around for years. If you had originally ripped all your stuff as MP3, you wouldn't be having this conversation with yourself every year.
You can tell a great deal about the character of a man by observing those who hate him.
I always thought this was a cool idea: http://file-ext-map.sourceforge.net/
Though not updated in a long while, I think you could use this to automatically convert your flac files to an "mp3 share" and the files would be automatically transcoded to mp3 on the fly as you viewed the Samba share. Just make additional shares for additional file types.
No need to batch process, whatever you want is done on the fly.
Sig!
Do a serch for etree scripts and or shn2mp3.
shn2mp3 is a perl script that can convert a folder of shorten files or flac files to mp3 or ogg.
this tool was written for live concert trading community so it is more tuned for concert recordings. ie it looks of the accomponing text info file for the concert, and uses the info in that file for the id3 tags (artist, date, venue, source).
I needed a command-line batch converter so I wrote one and posted it on sourceforge. Check out: http://wav2mp3.sourceforget.net/
I'm always willing to listen to feature requests. Sounds like a wav2flac equivalent might be something you'd want. I was driven to this solution because lame doesn't support multiple file inputs to convert.
You can cron the conversion so it happens after hours. Rip during the day, convert at night.
It's interesting that this question was posed at this time because I just went through this process with my own music collection recently. I ripped everything to FLAC and then did lots of testing and evaluation as to what file format would be best for my "portable" files. OGG is nice; AAC is Apple's choice (and therefore has a certain sex appeal to it); Sony are being their eccentric selves by going the ATRAC-3 route, and WindowsMedia is, well, WindowsMedia.
The bottom line is this: is there any digital music device that *cannot* play MP3? Will there ever be a format as pervasive as MP3? Until I have reasonable certainty that I can take audio in "format X" and have it play on every device under the sun, I will stick with MP3 for lossy audio -- because it plays on every device under the sun.
Flacattack is great. Configure a config file and Flacattack does the rest for you. Check out hydrogenaudio.org disuscussion on the lossless forum.
But then... digital distribution started last year with Apple iTunes, Napster, Rhapsody, etc. All of these companies REQUIRED that the encoded file (AAC, WMA, etc) come from the master WAV file. Ack! Screwed! 9 months of ripping down the drain!
So... we finally realized what I was kicking myself for not realizing in the first place - and exactly what the story post mentions: hard drive storage is cheap. labor is expensive. rip the CD *once*, lossless, and NEVER have to rip it again. We wiped all our useless MP3 drives and started again: ripping all 78,000 CDs to FLAC format. Since it's a perfect digital copy of the master audio fles, and supports metadata tags, too, it's the perfect archiving format.
VERY easy to just script-up a bulk converter. http://perl.pattern.net/transcode is a great Perl solution. I posted my audio-converter scripts here, which include the use of SOX to make 30-second audio clips (since we needed that for work).
To all those here saying "MP3 is fine!" - you're being short sighted. In a few years there will be a newer better codec, and all your old MP3s will look as bad to your ears as your old 320x240 JPGs from 1995 look now. Go lossless. (FLAC, WAV, etc) - your future self will thank you.
I totally agree with the original poster. I just made a similar decision and reripped all my (original) CDs to flac, see my weblog http://pkt3141592.blogspot.com/. I have made small scripts (~20 lines each) that convert flac2mp3, flac2vorbis and (flac)m3u to (mp3)m3u files. The neat thing is that I preserve all information tags across formats.
I usually invoke the mini scripts like : find -name \*.flac -exec flac2vorbis \{\} \; and it works really well. I encoded 35 albums from flac to mp3 for my personal portable audio player in very little time.
I am now considering an automated script that will generate .tex labels for every directory by reading information tags. It is not very hard to do but getting the output to look nice is going to be quite hard and my TeX skills are a little bit rusty.
As a side thought I might eventually make an SQL database out of all this music but I don't think my collection will ever grow that much. Anyway, this has been a toy project of mine in the last 3-4 days and it has proved quite useful. I may post the end result (propably a collection of perl and bash magic ;-)) somewhere on sourceforge if it becomes non-trivial.
P.
Hand it a playlist, and it'll convert the files in that playlist to MP3 format.
http://perlmonks.thepen.com/401680.html
Batch recursive FLAC to Ogg conversion scriptn verter.php
http://www.buberel.org/linux/batch-flac-to-ogg-co
Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
Over the years I've written a number of scripts to deal with lossless audio files (like FLAC and Shorten) and one of them is called "shn2mp3". It can convert SHN or FLAC files to MP3 or OGG files. It is targeted at live concert recordings that are accompanied by a text "info" file that describes the recording gear, setlist etc and this info is parsed and turned into tags. I wasn't, until now, aware of the "tagcopy" command used in another poster's sample script, but I think I'll knock up a new version of my scripts that can be used with this app so as not to require the error-prone text file parsing logic. You can find shn2mp3 and other scripts at: http://etree-scripts.sourceforge.net/ Hope this helps some people.
Use the audio player foobar 2000 and it's "diskwriter" plugin for the conversions. It's simple and provides support for more audio formats than you'll know what to do with.
I'll create an amusing sig when I have something meaningful to post.
Agreed! Ripping is labor-intensive, and metadata is even more so. Getting the FLAC tags right the first time will make everything easier down the road.
Some time ago, I proposed a way to handle metadata externally, by simply giving each file a name like [cddb-disc-id][tracknumber].extension and then tagging each target format from the local cddb cache.
How do you handle it if a metadata error is found later? Is there an easy way to regenerate the tags for all the formats when someone edits the master?
You know what I never ever understand about ripping. If you have some extremely old CDs, how in the world do you get the labels out of the songs. Wouldn't you have to label song by song manually by hand? You can do it at home, but how do big companies do so freaking many CDs?
Found this useful software:
.flac files on your (Samba) server, and have them appear as .wav files as well, with the server converting them as they are requested.
http://file-ext-map.sourceforge.net/
It's a Samba 2.2 virtual file extension.
So you can save a bunch of
I dare say you could also arrange conversion to mp3 and ogg on the fly as well, though obously not fast enough to keep a 48x cd writer happy.
Completely agree. There is no reason to use anything other than MP3.
I'd like to rip CDs under Windows, primarily so my wife can rip without needing to switch from her current PC. They'll be etracted to 16bit, 44.1k .wav files and written to a share on a Linux box. From there, I'd like to have the Linux box check the folder every once in a while (via cron I assume) for new files to be encoded. Once it sees a new file, it should encode it to both MP3 and FLAC with id3 tags, and then delete the original. Additionally, I'd like to have the ability to add PCs running Linux (ideally using some sort of CD-bootable distro) to distribute the encoding.
I know I could do this using Perl/Bash/etc., via cron to make a watch folder and lock files for other machines to signal that they're working with a file. Before I do all that... is there anything out there which does some or all of what I'm trying to do?
I hope the mod-gods will allow a brief tangential rant.
My prediction: all the people who rip or purchase audio in lossy formats today will hate their decision in a few years. (The only exception is, of course, ripping audio destined solely for a portable player - which is a very different scenario from trying to archive audio in compressed formats.)
Sure - an mp3 file sounds pretty good, most of the time. It's stunning that it sounds as good as it does. But, it doesn't sound perfect.
Reasonable people may object that even with perfect hearing and a great pair of headphones, one would only notice a difference between a "lame --preset extreme" file and the original in one album out of a thousand. That's probably true. The same sure isn't true about a 128 cbr file, of the sort one can buy online from a dozen vendors for the same price as a CD - it isn't hard to find a track full of noticeable artifacts when made with the best encoder around. People who encode things are even lower rates ("because it's mostly speech anyway") really shouldn't have to wait around in order to hate themselves - there's plenty of reason to feel bad right now.
So, why not assume it's good enough and not worry? Here's the catch: the cost of archiving audio in a lossless format is very small today, and will become vanishingly small over the next few years. For something like 15 cents an album at the price of a hard drive (much less if you're archiving to dvd and you buy disks on sale), you can guarantee for all time that your audio will always be good enough. It will sound great on the headphone you're going to buy in five years, to the audiophile spouse you haven't yet met, and even when chopped up added to an audio mix when some radio station geek digs it out of an estate sale seventy five years from now.
In ten years, when the additional cost of storing your entire audio library in lossless format drops to the price of a meal, you'll hate yourself for not having done so. (Of course those of you silly enough to buy tracks with drm limits on the number of machines on which it can be played are going to hate yourselves much more, and probably somewhat sooner.)
Just think how annoying it is when you hear a recording of some great, lost radio program that was made on a consumer tape deck set to "long play." If you're anything like me, you curse the short sighted people who bargained away the future for the cost of a dollar cassette.
And don't assume that you can just run out and pick up a new copy of the album. Even within the mainstream music industry, there are countless lost albums whose masters have been destroyed, and many more which lie abandoned with no promise of a reprinting. There's no reason to believe things will be any different in the future.
Anyway - to be slightly more on topic - I agree, FLAC is great. Don't know of any exiting conversion utilities, however it would take more than a few dozen lines of perl to throw something together. There are command line tools to rip a cd, run a database lookup, and encode to most formats.
If you want to make it slighly less annoying, hit a pc junker store and pick up as many cheap old cdrom drives as you have IDE slots. That'll make the disk changing somewhat less annoying. (If you want to go nuts, pick up five 486 pc's, and fill them all with cd drives... that is, assuming spending a weekend setting up an automated super-ripper sounds like more fun than spending a weekend babysitting your cdrom drive.)
I've converted 70+ LPs (yeah I'm old and creaky but so's yer mama) to WAV format. I agree with a poster who said metadata is hard - I had to name all of those wav files with song titles and put them in folders (this is Windows, but that doesn't matter really). I'm assuming if I want to go from WAV to FLAC that I'll need to enter all the metadata for the tags again manually? are tags the _only_ advantage over WAV (stereo 16-bit 44.1KHz i.e. supposedly CD-Audio standard) files? I'd like to get a handle on this question before I start on the cassettes. The goal is to be all digital.
I went though the same thing as this guy did then one day I said "FUCK IT" and I have gone done the AAC path. Used MP3, OGG, FLAC and there has always been some reason I have had to change. The main reason I went with AAC(MP4) is becasue I got an iPod, MP4 is on par with OGG(give or take) and it works in Winamp. I will never use WMA and for the poor people out there that uses this format I feel sorry for you :)
Trying to keep everyone happy is a waste of time and effort if they want my music then I am more than happy to hook them up but they will just have to deal with the fact that I use AAC(MP4). If they only use Media player then they are shit out of the luck and will have to install iTunes or Winamp(Would more push Winamp, I only use iTunes to rip and upload to my iPod).
Merry Xmas!!!
"The most dangerous creation of any society is that man who has nothing to lose." - James Baldwin, American author