Last active
August 21, 2024 07:58
-
-
Save mlen/4379799 to your computer and use it in GitHub Desktop.
FLAC to ALAC converter.
Requires Mac OS X and `flac` binary installed (ie. via Homebrew: `brew install flac`).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
convert_to_alac() { | |
flac="$1" | |
aiff="${flac%.*}.aiff" | |
alac="${flac%.*}.m4a" | |
flac -s -d --force-aiff-format -o "$aiff" "$flac" | |
afconvert -f m4af -d alac "$aiff" "$alac" | |
rm "$aiff" | |
} | |
if [ $# -ne 1 ]; then | |
echo "usage: $0 dir" | |
echo "requirements: Mac OS and flac installed" | |
exit 1 | |
fi | |
for file in "$1"/*.flac; do | |
echo -n "." | |
convert_to_alac "$file" | |
done | |
echo " done" | |
I don't think you need Homebrew or to install anything... here's how I do it on Mojave and Catalina:
export IFS=$'\n'
for x in `ls *.flac`; do afconvert -v -f m4af -d alac $x ${x%flac}m4a; done
absolutely perfect. Had no idea afconvert
just existed like that! Thank you.
It's very handy, thanks!
For anyone who may need it: I've also made another version based on ffmpeg
which also downsamples the audio to 16bit / 44100kHz, otherwise my iPod was stuttering when playing files with 32bit sample size 😬 It's here: https://gist.github.com/pltb/244899d900a1b0305467f50e32133cc3
(I couldn't make flac
or afconvert
downsample the audio, and was too lazy to dig deeper, so just used ffmpeg
😅 )
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may also use iDealshare VideoGo to convert FLAC to ALAC without quality loss.
It also helps to convert ALAC to FLAC and convert between FLAC, ALAC, M4A, WAV, MP3, AAC, WMA, OGG, OPUS etc
It also helps to extract FLAC, ALAC from video files or convert between video formats.
Here is the easy guide https://www.idealshare.net/audio-converter/flac-to-apple-lossless.html