12

I'm wondering if anyone has a clean, painless workflow for losslessly transcoding FLAC files to their equivalent ALAC? It's supposed to be a bit-perfect conversion, meaning it shouldn't be very hard, but.... it is.

Why would I do this? (Before the OS folks eat me alive) Mainly, because an audio app that I use (Serato Scratch Live) does not support FLAC, and despite the constant prodding of users over the last five(!) years, most likely will not for a while. They did, however, hack together ALAC support

Also, it would seem that getting iTunes to play FLAC files (and properly downconvert them to use space efficiently on my iPod) is pretty much impossible.

The only catch is that I'd like to preserve some weird, offbeat meta tags (BPM and song key) that would be a bit painful to regenerate. I'm down with anything on Windows or Linux

Thanks

Tom

10 Answers 10

13

In Ubuntu, you can open a terminal, navigate to the directory in question, and do the following command loop:

for f in *.flac; do ffmpeg -i "$f" -acodec alac "${f%.flac}.m4a"; done
  • Will convert all .flac files in the directory to .alac files, doing so in a bit-perfect way.
  • ffmpeg doesn't come packaged with Ubuntu, so you'd need to install that from repos; however, I can't say for sure that this will keep your BPM tag info.

Also, it would seem that getting iTunes to play FLAC files (and properly downconvert them to use space efficiently on my iPod) is pretty much impossible.

There's a program called flukeformac that may allow you to play .flac files in iTunes.
As to conversion for efficient iPod use, the following command loop will do the trick:

for file in *.flac; do $(flac -cd "$file" | lame --preset fast extreme - "${file%.flac}.mp3"); done`
  • You may want to replace --preset fast extreme with a lower bitrate option
    (more on lame presets)
3
  • 1
    An excellent, comprehensive answer. Thank you Aug 4, 2011 at 5:10
  • I tried to use the static build of ffmpeg in windows 10, it can convert acodec alac but it can't convert vcodec h264 although h264 is a supported format in ffmpeg --codecs Feb 10, 2019 at 10:25
  • Note to Windows users who are not yet familiar with the command shell: The Windows equivalent of this is for %F in (*.flac); do {path_to_ffmpeg.exe} -i "%F" -acodec alac "%~nF.m4a"
    – Asker
    Jan 30, 2021 at 23:56
6

For Windows using PowerShell and ffmpeg (based on @boehj answer):

Ls -Recurse -Include *.flac | %{C:\path_to_ffmpeg\ffmpeg.exe -i $_.FullName -acodec alac ($_.DirectoryName+"\\"+$_.BaseName+'.m4a')}
5

dBpoweramp can convert FLAC to ALAC; after installing, get the needed codecs here.

.

4

To the (Windows) command-line addicts out there:

I've written an automation script for iTunes for Windows that batch imports all FLAC files from the given folder and its subfolders into iTunes in ALAC format, preserving the key metainformation such as album, artist and song name. It requires flac.exe and metaflac.exe and a small helper utility for charset conversion. You can download a ready-to-use package that includes those dependencies (see below) or fork my project on GitHub.

For the full story, binary download, limitations, etc., refer to my blog post.

2

In Windows you can open a command prompt and run the following commands to convert the FLAC files to ALAC in the same directory on a different drive (the way I prefer to have it) using qaac, libFLAC and iTunes:

  1. change the current working directory to the source directory containing your flac files (s:\music is used here as an example)

  2. copy all your folders to the destination directory, including the album front cover files with the file names (folder.(jpg|png|gif)):

    robocopy "s:\music" "d:\music" folder.jpg folder.png folder.gif /E

    The option /E includes the empty directories. If you don't want them copied use the /S option.

  3. use qaac to convert all the FLAC files in that directory to ALAC files on the other drive in a 'bit perfect' way and keeping most of the original metadata:

    FOR /R %I IN (*.flac) DO qaac64 -A --copy-artwork -o "d:%~pI%~nI.m4a" "%I"

    Inserting IF NOT EXIST "d:%~pI%~nI.m4a" into the above command after DO will skip converting files that already exist in the destination directory.

Please note that

  • the directory names on the source (s:) and destination (d:) drive need to be the same (otherwise you need to tinker with the variables in the FOR command, qaac won't create the directories for you)
  • you need to change into the source directory (s:\music in the above example) for the commands to work
  • the destination directory (d:\music in the above example) should be empty to avoid overwriting files
  • you can use the SUBST command to map a directory to a drive letter if you want to create the ALAC files on the same drive
  • you'll have to run at least version 2.57 of qaac and use the appropriate binary for your windows version (32bit or 64bit)
  • qaac needs to be in your Windows PATH variable or you'll have to include the full path to its binary in the FOR command above
  • qaac needs iTunes or QuickTime installed to work
  • qaac needs a matching copy of the libFLAC DLL in its directory to read FLAC files, you can find it on the rarewares site
  • iDevices can't handle files with sample rates above 48,000 kHz and sample sizes above 24 bit (at the beginning of 2016). iTunes won't let you copy these files to your device, warning you that the track "was not copied because the sample rate is not supported by the" iDevice. Calling qaac with the options --rate 48000 --bits-per-sample 24 will fix this, but make sure to only use these options on the actual high definition files, because otherwise you'll bloat all of your files without gaining anything!
  • the ALAC files will be missing the volume information that Apple iTunes and iDevices rely on for their Sound Check-functionality (adjusts song playback volume to the same level). The information can be added to the files using iTunes (only seems to store volume information in it's library), beaTunes (commercial software), iVolume (commercial software) and a number of other tools on different plattforms
  • this isn't a synchronization-workflow: the above commands run a second time will add FLAC files you've added to the source directory to your destination directory but won't keep two directories of your music in sync (renamed files will result in duplicated ALAC files with different names, deleted files won't be deleted from your destination directory, if you're using IF NOT EXIST metadata-changes since the last run won't be reflected in the ALAC files)
1
  • Welcome to Super User! Thanks for posting such a comprehensive first answer. :)
    – Excellll
    Jan 20, 2016 at 22:17
1

FFmpeg should be able to do it; it's up to you to find the correct commands to do so.

1
  • This is an ancient post, but it's really more of a comment than a solution. Please consider expanding the answer. Thanks.
    – fixer1234
    Apr 2, 2016 at 6:15
1

I kept finding myself asking similar questions for different formats so I made https://www.blisshq.com/music-library-management-blog/2017/06/20/matrix-free-audio-file-converters/

That page says... foobar2000. So it depends what you mean by "painlessly" - it's free as in beer.

1

There are multiple ways to convert FLAC to ALAC.

  • On Windows, you can use foobar2000 and the Encoder Pack.
  • On Windows, Linux, and Mac, you can use PowerShell, flac, and ffmpeg.

    $folder = "d:\demo"
    
    # Convert flac to wav
    Get-ChildItem -Recurse "$folder\*.flac" | ForEach-Object {
      & C:\tools\flac.exe -d --force --silent $_.FullName
    }
    
    # Convert wav to alac
    Get-ChildItem -Recurse "$folder\*.wav" | ForEach-Object {
      $filename = [System.IO.Path]::ChangeExtension($_.FullName, ".m4a")
      & C:\tools\ffmpeg.exe -hide_banner -loglevel panic -i $_.FullName -acodec alac -sample_fmt s16p $fileName
    }
    
    # Remove wav and flac file
    Get-ChildItem -Recurse "$folder\*.wav" | Remove-Item
    Get-ChildItem -Recurse "$folder\*.flac" | Remove-Item
    

Check my blog post for more details: Convert music files from FLAC to ALAC

0

MediaMonkey can do this as well, but it'll only preserve BPM tag (I'm not aware of Song Key being a standardized tag across these formats).

note: you'll need to purchase the 'MediaMonkey Codec Pack' for ALAC encoding.

0

I'm using FooBar and iTunesEncode for its converter.

  1. Get iTunesEncode
  2. Go to FooBar > Select all in your FLAC playlist > Right-click - Convert
  3. Right side > Formats > Custom

    Encode Tool : path to iTunesEncode.exe
    Extension : m4a 
    Parameters : -d -e "Lossless Encoder" -a "%artist%" -l "%album%" -t "%title%" -g "%genre%" -y %date% -n %tracknumber% -i %s -o %d
    Format is: lossless
    next propery : 24
    
    DisplayInfo example :
    "Encoder name" - iTunes
    "Bitrate" - 1000
    "Setting" - Apple Lossless
    
  4. Fill other parameters to convert > Save the configuration (optional) > Convert

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .