Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a reasonable sized music collection that I keep in FLAC format on my Ubuntu laptop. I'd like to start playing this music on my Mac, and to sync it from there to my iPod. People have suggested that the best way to do this is to convert my collection to ALAC, and I've decided that's what I want to do.

Before I dive in and write custom shell scripts that call ffmpeg through some complex find command, I thought I'd ask for advice.

How can I best convert my existing FLAC collection to ALAC, without any loss of audio quality and preserving all of the metadata?

share|improve this question
    
Huh. I'm surprised. I thought there'd be an obvious choice for transcoding tool, but all the ones I can find are focused on video. –  RAOF Feb 28 '12 at 2:28
    
What I ended up doing here was writing a custom Python script that called metaflac, ffmpeg and AtomicParsley. –  jml Apr 2 '12 at 10:24

2 Answers 2

avconv (or ffmpeg, which avconv is a fork of) can do this from the command line:

avconv -i input.flac -c:a alac output.m4a

It should preserve the metadata by itself.

To do every flac in a directory:

for f in ./*.flac; do avconv -i "$f" -c:a alac "${f%.*}.m4a"; done

To do every flac recursively (in the current directory and all sub-directories):

shopt -s globstar
for f in ./**/*.flac; do avconv -i "$f" -c:a alac "${f%.*}.m4a"; done

If you've got the flacs in ogg files or something, obviously change ./*.flac to ./*.ogg.

I think this should work with avconv/ffmpeg from the repositories (since ALAC is released under the Apache license, and can be legally distributed), though I have the version from medibuntu installed.

If you want to get rid of the original files, you can put rm into the loop. This version uses the -n flag for avconv, so it will not overwrite any already-existing ALAC files, and using && instead of ; means that if avconv stops with an error then the original FLAC file will not be deleted:

for f in ./*.flac; do avconv -n -i "$f" -c:a alac "${f%.*}.m4a" && rm "$f"; done

Note that deleting files with rm is irreversible (outside of forensic data recovery), so be careful using it.

share|improve this answer
    
Do you know how to replace the flac files by alac ones, instead of making an alac copy of the flac file? –  user138784 Mar 24 '13 at 14:22
    
@user13 no, avconv/ffmpeg cannot do that, it cannot overwrite the files it uses as input. You could use rm to remove the original files, if you wish. –  evilsoup Mar 24 '13 at 14:25
    
I'm not really a command line guru (I'm quite new to GNU/Linux), so up to now I used to remove them manually. (nautilus, arrange files by type, and then I can just select al the .flac files in that directory and remove them). I will have a look at how this "rm"-thing works. :) –  user138784 Mar 24 '13 at 14:51
    
@user138 I've edited the answer to show one implementation with rm - though do take note of the warning, rm is pretty much irreversible, it outright deletes the files rather than moving them to the trash bin. Another alternative would be to use globbing after the loop is finished (so you can check that there have been no problems... if the command failed for whatever reason, you wouldn't want to get rid of your originals): rm -- *.flac would remove every FLAC in the working directory. –  evilsoup Mar 24 '13 at 16:21
    
Thanks for the advice! I normally keep the original flac files in another directory, so there is no risk of losing them. –  user138784 Mar 24 '13 at 17:12

I don't use Mac, but FLAC is free and has codec for all the platforms, so I think that the better way to do it is converting it from Mac directly.

share|improve this answer
    
Thanks, but I'm firmly resolved to re-encode my collection to ALAC. –  jml Feb 26 '12 at 22:19
    
Ok, but what I was saying is that you should to it from Mac direcly :) Reading online, on Ubuntu the better thing you can do is using ffmpeg, as shown here: ubuntuforums.org/showthread.php?t=889700 Obviously I think you can use one of the GUI for ffmpeg, you shouldn't do it from terminal. –  dadexix86 Feb 27 '12 at 9:08
2  
alac is released under Apache license. –  daithib8 May 23 '12 at 20:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.