Andrey Krisanov

Production LLM inference, AI infrastructure, and distributed systems

Convert FLAC to Apple Lossless with FFmpeg

Convert FLAC to Apple Lossless (ALAC) with FFmpeg while preserving audio quality and metadata, then import the files into Apple Music.

2 min read
#ffmpeg #apple-music #audio #flac #alac

I'm a longtime Apple Music user. Most of my so-called music collection is on the streaming service. However, I occasionally buy rare or remastered releases ripped from CDs. These releases are usually in the FLAC format, which Apple Music doesn't support. But I've found an easy workaround that allows me to organize and play albums on the go.

The centerpiece of the workaround is FFmpeg. So if you don't already have it installed, it's worth installing now:

brew install ffmpeg

Install FFmpeg with Homebrew

When the tool is ready to use, navigate to the folder containing the FLAC files and run the following script:

for file in *.flac; do ffmpeg -i "$file" -acodec alac -vcodec copy "`basename "$file" .flac`.m4a"; done; mkdir flac; mkdir alac; for file in *.flac; do mv "$file" "flac/"; done; for file in *.m4a; do mv "$file" "alac/"; done;

A one-liner that converts FLAC files to ALAC

FLAC files for Susumu Hirasawa's album Siren in Finder
Susumu Hirasawa – Siren [Limited Edition]

The bash script converts the audio to the Apple Lossless format (*.m4a) and moves the files to the alac directory:

Converted M4A files in the ALAC directory in Finder

Finally, the alac directory can be dragged to Apple Music to import the album and upload its tracks to the cloud.

The imported Siren album in Apple Music
The uploaded album