Convert Big-Endian to Little-Endian PCM with FFmpeg

Converting audio files from big-endian PCM to little-endian PCM is a common task when working with legacy audio formats, hardware equipment, or specific platform requirements. This article provides a straightforward guide on how to use the FFmpeg command-line tool to quickly change the byte order (endianness) of your PCM audio files. You will learn the exact commands needed for both standard container files (like WAV) and raw PCM data.

Converting PCM in Standard Audio Containers

If your big-endian PCM audio is wrapped in a container format like WAV, AIFF, or AU, FFmpeg can automatically detect the input parameters. You only need to specify the desired little-endian audio codec for the output.

To convert a 16-bit big-endian PCM file to a 16-bit little-endian WAV file, use the following command:

ffmpeg -i input_big_endian.wav -c:a pcm_s16le output_little_endian.wav

Command breakdown: * -i input_big_endian.wav: Specifies the input file. * -c:a pcm_s16le: Sets the audio codec to signed 16-bit little-endian PCM. * output_little_endian.wav: The name of the converted output file.

Choosing the Right Bit Depth

Ensure you match the bit depth of your source file to prevent quality loss or unnecessary file size inflation. Here are the common target codecs for little-endian PCM:

For example, to convert to 24-bit little-endian PCM:

ffmpeg -i input_be.wav -c:a pcm_s24le output_le.wav

Converting Raw PCM Files

Raw PCM files (often with .raw, .pcm, or .bin extensions) do not contain headers. Because of this, FFmpeg cannot automatically detect the sample rate, channel count, or input format. You must explicitly define these input parameters before the input file flag (-i).

To convert a raw, 16-bit big-endian, stereo PCM file at 44.1 kHz to a little-endian WAV file, run:

ffmpeg -f s16be -ar 44100 -ac 2 -i input.raw -c:a pcm_s16le output.wav

Command breakdown for raw input: * -f s16be: Tells FFmpeg the input format is raw, signed 16-bit big-endian PCM. * -ar 44100: Sets the input audio sample rate to 44,100 Hz. * -ac 2: Sets the input channel count to 2 (stereo). * -i input.raw: Specifies the raw input file. * -c:a pcm_s16le: Encodes the output to signed 16-bit little-endian PCM.