How to Set Sample Format to 24-bit PCM in FFmpeg
This article provides a quick guide on how to configure FFmpeg to output audio using a 24-bit PCM sample format. You will learn the exact command-line arguments required for raw PCM audio containers like WAV, as well as how to specify 24-bit depth for compatible compressed formats like FLAC.
To set the audio sample format to 24-bit PCM in FFmpeg, you primarily
use the audio codec flag (-c:a) to select a 24-bit PCM
encoder. The most common standard for 24-bit PCM is signed
little-endian, represented in FFmpeg as pcm_s24le.
Converting Audio to 24-bit PCM WAV
To convert any audio or video file into a standard 24-bit PCM WAV file, use the following command:
ffmpeg -i input.mp3 -c:a pcm_s24le output.wavIn this command: * -i input.mp3 specifies your input
file. * -c:a pcm_s24le sets the audio codec to 24-bit
signed little-endian PCM. * output.wav is the resulting
output file.
Converting to 24-bit PCM Big-Endian
If you require a big-endian format (often used in formats like AIFF),
use the pcm_s24be codec instead:
ffmpeg -i input.wav -c:a pcm_s24be output.aifUsing the Sample Format Flag for Compressed Formats
When encoding to formats that support multiple bit depths, such as
FLAC, you use the -sample_fmt flag to explicitly request
24-bit resolution.
To encode a file to 24-bit FLAC, use:
ffmpeg -i input.wav -c:a flac -sample_fmt s24 output.flacHere, -sample_fmt s24 tells the FLAC encoder to use a
24-bit sample depth.
Verifying Supported Sample Formats
To see a list of all sample formats supported by your installed version of FFmpeg, run the following command:
ffmpeg -sample_fmtsThis command outputs a list of formats (such as s16,
s32, s24) along with their bit depths, helping
you choose the correct format for your target encoder.