LinuxCommandLibrary

afconvert

Convert audio file formats

TLDR

Use a specific extension (default: aff)

$ afconvert -a [extension] [path/to/input_file] [path/to/output_file1 path/to/output_file2 ...]
copy

Use a specific compression level (default: 7)
$ afconvert -X[0..7] [path/to/input_file] [path/to/output_file1 path/to/output_file2 ...]
copy

SYNOPSIS

afconvert [options] input_file output_file

PARAMETERS

-f
    Specifies the output audio format using a four-character code (e.g., 'm4af' for M4A, 'WAVE' for WAV).

-d
    Specifies the output data format, including codec settings. Common options include 'aac' for AAC, 'alac' for Apple Lossless, and 'ima4' for IMA4.

-s
    Sets the sample rate of the output audio (e.g., 44100, 48000).

-b
    Specifies the bit rate for the output audio (e.g., 128000 for 128 kbps).

-c
    Sets the number of channels in the output audio (e.g., 1 for mono, 2 for stereo).

-v
    Enable verbose output.

-q
    Specifies the audio quality level. Values typically range from 0 to 127.

DESCRIPTION

The afconvert command is a command-line tool on macOS used for converting audio files between different formats. It's a powerful utility included with the operating system, providing a flexible way to manipulate audio. afconvert supports a wide range of audio codecs and formats, allowing users to change the audio encoding, sample rate, bit depth, and number of channels of an audio file. It's commonly used for tasks like creating audio files suitable for different devices, optimizing audio for web use, or transcoding audio to a more compatible format. It relies on the Core Audio framework for its audio processing capabilities. It's particularly useful for batch processing audio files and integrating audio conversion into automated workflows or scripts.

CAVEATS

afconvert is specific to macOS and not available on other operating systems like Linux. The availability and specific options might vary slightly depending on the macOS version.
Some format conversions might require specific codecs to be installed.

<B>FORMAT CODES</B>

The -f option requires four-character format codes. To view a list of available formats, use afconvert -h. Common examples include: 'AIFF', 'WAVE', 'm4af', 'caff'.

<B>DATA FORMAT CODES</B>

The -d option determines the audio codec. To see the available data format codes, use afconvert -h.
Examples: 'aac', 'alac', 'mp3'.

HISTORY

afconvert has been included with macOS since at least Mac OS X 10.4 (Tiger). It provides a streamlined way to leverage the Core Audio framework for audio format conversion from the command line. Its usage has remained consistent over the years, making it a reliable tool for audio manipulation on macOS.

SEE ALSO

sox(1), ffmpeg(1)

Copied to clipboard