Slashdot Mirror


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?"

27 of 94 comments (clear)

  1. sounds like a job for by Gherald · · Score: 4, Insightful

    bash

  2. just a simple frelling script. by Gadzinka · · Score: 4, Informative
    Well, I don't know about applications to recode to different formats, but I do use mp3 for transferring music to my Creative MuVo. It was just a simple script written in couple of minutes:
    #! /bin/sh

    br="96"

    if [ "$1" = "-b" ] ; then
    br="$2"
    shift;shift
    fi

    sdir=`echo "$1"|sed 's|/$||'`
    ldir=`dirname "$sdir"`
    ddir=/home/queue

    if file "$sdir" | grep -qs directory ; then
    find "$sdir" -print | while read src ; do
    dst=`echo "$src" | sed "s|$ldir|$ddir|; s/\.\([oO][gG][gG]\|[fF][lL][aA][cC]\|[mM][pP]3\)$ /.mp3/"`
    case `file -b "$src"` in
    *directory* )
    mkdir "$dst"
    ;;
    *FLAC* | *Vorbis* )
    ogg123 -d wav -f - "$src" |lame -h --abr "$br" - "$dst"
    tagcopy "$src" "$dst"
    ;;
    *MP3* )
    lame -h --abr "$br" "$src" "$dst"
    tagcopy "$src" "$dst"
    ;;
    * )
    cp "$src" "$dst"
    ;;
    esac
    done
    fi
    You have to give it full path from / and tagcopy is a simple wrapper around taglib C API to copy ID3 (or equivalent) tags between two files.

    Just use it as an example to create scripts converting to other formats.

    Robert
    --
    Bastard Operator From 193.219.28.162
  3. Konqueror + kio_audiocd by MarkKnopfler · · Score: 2, Interesting

    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.

  4. A summary by dasunt · · Score: 3, Informative

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

    1. Re:A summary by harrkev · · Score: 2, Interesting

      Well, I think that the original question answered this one pretty well.

      MP3 is the universal format, but newer codecs can do more with less bits. As a result, using another codec, you can have more songs for the same quality, or more quality for the same number of songs. The problem is that there is no such thing as a universal next-generation codec. Apple has their own (DRM galore), Microsoft has their own (mega-DRM galore), and OSS people have their own. And no device that I know of supports all of them (and if it did, I couln't afford it).

      So, the approach of the original post seems valid. Grab everything as FLAC, and convert to other formats as needed. Less than $100 (after rebates) at your local computer superstore will get you enough space to hold over 500 CDs worth of music in FLAC.

      --
      "-1 Troll" is the apparently the same as "-1 I disagree with you."
  5. One thing I have wanted to use by Christopheles · · Score: 2, Interesting

    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.

  6. Why? by samael · · Score: 3, Insightful

    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?

    1. Re:Why? by Gherald · · Score: 2

      Why not just rip to high-quality MP3 and have done?

      Maybe because that wouldn't make for a particularly interesting Ask Slashdot.

    2. Re:Why? by richy+freeway · · Score: 3, Insightful

      Cos when the next super MP3alike comes along, he'll have to rip all the tracks again to get the best quality. If he rips them all to a lossless format once, then converts to mp3 now, he can always return to the lossless format and covert them to the new super MP3alike format. Geddit?

    3. Re:Why? by Fweeky · · Score: 2, Insightful

      Because I want a proper backup of my music, with no worries over encoder quality or settings or format limitations or codec choice. Plus, the lossy settings I might use for a portable are probably not the same as those I'd use for my desktop.

    4. Re:Why? by SillyNickName4me · · Score: 2, Insightful

      > You know, burn a lossless format to CD-R or something.

      Because CD-Rs don't last. Yeah, I can buy them from some brand that gives a lifelong warantee, but really, no amount of money or replacement of CD-Rs is every going to get me back a unique recording so that is utterly pointless.

      Many CD-Rs that I have used so far fail to last for as long as I tend to keep music around, and those that did survive also did degrade noticably (substantially more errors and more jitter when played back on an audio device) Yeah, that was after approx a decade of storing a cd in its jewel case on a spot protected from sunlight and excesive heat and cold.

      > Why not just use the CDs themselves as a long-term storage of a lossless format?

      Scratch scratch, oops, CD unreadable.

      Harddisks fail as well, but solutions to prevent dataloss from disk failure are way more practical for those (mirroring, raid)

      Anout the only better alternative is to burn things to opticals (CD or DVD) in a very clean environment, verify them for proper working, and then seal them into a container with controlled atmosphere, temperature and light (or actually, lack of light). Whenever you need the backup, the first thing you have to do after breaking the seal is repeating the backup process in order to create a new known good backup.

      Of course all hardly relevant unless you care about keeping your music collection around for more then say a decade.

  7. The Master Of Audio by Goo.cc · · Score: 2, Informative

    Go to this website:

    http://www.hydrogenaudio.org/

    (Read and search the site before asking any questions.)

  8. Makefile by xFallenAngel · · Score: 5, Interesting
    You could actually write a makefile that utilizes the separate converters and outputs as wanted...

    make ogg
    make mp3
    make wma
    make rip

    Something alont those lines...I'll leave the Makefile as an excersize for the reader :)

    1. Re: Makefile by Black+Parrot · · Score: 3, Funny


      > You could actually write a makefile that utilizes the separate converters and outputs as wanted...

      > make ogg
      > make mp3
      > make wma
      > make rip

      Don't forget the all-important -

      make morediskspace

      --
      Sheesh, evil *and* a jerk. -- Jade
  9. The script I use... by turnerjh · · Score: 4, Informative

    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

  10. Why? No, you don't. by mbourgon · · Score: 4, Insightful

    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
  11. Indeed by turgid · · Score: 2, Informative
    And if you don't know much about bash scripting, you could do a lot worse to learn about it here.

    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 :-)

  12. Cool idea by megaversal · · Score: 5, Interesting

    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!
    1. Re:Cool idea by 2TecTom · · Score: 2, Interesting

      yes, it is ... in fact, I see no real reason an advanced file system couldn't allow you to access, on the fly, a file in any format the system is capable of reformatting it to. Not only that, but savvy apps should be able to inquire if a file can be reformatted on the fly into a useable format if an incompatibility is encountered.

      take this far enough and you see a universal file system that can proffer data in the format the app requests no matter the way it is stored.

      just a thought

      --
      Words to men, as air to birds.
  13. What about wav2mp3/wav2ogg? by CertGen · · Score: 2, Informative

    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.

  14. MP3 Will Live Forever by parvenu74 · · Score: 2, Interesting

    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.

  15. Smart choice with FLAC! We learned the hard way! by linuxbaby · · Score: 3, Informative
    At CD Baby we used to think like the other folks here saying "Why not just use MP3?" We have over 78,000 CDs here, and we hired two people to rip them all to hi-fi MP3 (lame --preset standard).

    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.

  16. Exactly my thoughts... by ponos · · Score: 2, Insightful

    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.

  17. Here's two scripts to do what you want by Matt+Perry · · Score: 2, Informative
    Here's two scripts to do what you want:

    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 script
    http://www.buberel.org/linux/batch-flac-to-ogg-con verter.php

    --
    Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
  18. etree-scripts / shn2mp3 by Bklyn · · Score: 2, Informative

    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.

  19. Re:You need a seperate tool? by delus10n0 · · Score: 2, Informative

    When I rip with Exact Audio Copy, I have it throw Various Artist rips into a seperate directory, and then I use FooBar to add a "Compilation = True" tag to the files, before I use FooBar to rename them out to their final directories. Using FooBar's scripting, you can pull something off like this: /$if(%compilation%,Compilations,%artist%)/%album% [%date%]/%tracknumber% $if(%compilation%,%artist% - ,)%title

    That will add the "Artist - " in front of the song titles and stick them under Compilations, if they are tagged as such (like I mentioned before.)

    It seems tedious, but it's really not that difficult.

    For tagging, you might want to check out MusicBrainz, it only works on MP3s, but it can scan the MP3's contents and try to guess the proper tag data.. it's actually fairly accurate. For general tagging, I use a program called TheGodfather. It's able to tap into Amazon.com for album cover images, and a user supplied script (on the GodFather forums) can read directly from AllMusic.com

    --
    Not All Who Wander Are Lost
  20. Lossless audio is the way to go. by munpfazy · · Score: 2, Interesting

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