How to Decode Apple Lossless ALAC Using FFmpeg
This article provides a straightforward guide on how to decode Apple
Lossless Audio Codec (ALAC) files using FFmpeg. You will learn the exact
command-line syntax to convert ALAC files (typically found in
.m4a containers) into uncompressed or widely supported
lossless formats like WAV or FLAC, ensuring a seamless audio transition
without any quality loss.
Basic Decoding to WAV
FFmpeg includes a native ALAC decoder, meaning you do not need to
install any external libraries to read these files. To decode an ALAC
.m4a file into an uncompressed .wav file, use
the following basic command:
ffmpeg -i input.m4a output.wavIn this command: * -i input.m4a specifies your source
Apple Lossless file. * output.wav is the target filename.
FFmpeg automatically detects the .wav extension and decodes
the ALAC stream to uncompressed PCM audio.
Decoding to FLAC
If you want to keep the file size compressed while maintaining lossless quality and improving compatibility with non-Apple devices, you can decode ALAC directly to FLAC:
ffmpeg -i input.m4a -c:a flac output.flac-c:a flactells FFmpeg to use the FLAC encoder for the output file.
Controlling Bit Depth and Sample Rate
By default, FFmpeg will preserve the original sample rate and bit depth of the ALAC file. However, if you need to force a specific bit depth (for example, converting a 24-bit ALAC file to a 16-bit WAV file), you can define the audio sample format:
To decode to 16-bit PCM WAV:
ffmpeg -i input.m4a -c:a pcm_s16le output.wavTo decode to 24-bit PCM WAV:
ffmpeg -i input.m4a -c:a pcm_s24le output.wavBatch Decoding Multiple Files
If you have an entire folder of ALAC .m4a files that you
need to decode, you can automate the process using a simple command-line
loop.
For macOS and Linux (Terminal):
for f in *.m4a; do ffmpeg -i "$f" "${f%.m4a}.wav"; doneFor Windows (Command Prompt):
for %i in (*.m4a) do ffmpeg -i "%i" "%~ni.wav"These loops will search for every .m4a file in the
current directory and decode it into a corresponding .wav
file with the same filename.