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 <format>
    Specifies the output container format (e.g., 'aiff', 'caf', 'mp4f', 'wav').

-d <data_format>
    Sets the output audio data format or codec (e.g., 'LEI16' for 16-bit little-endian PCM, 'aac ', 'mp3 ', 'flac', 'alac'). Note the space for some 4-char codes.

-r <rate>
    Defines the output sample rate in Hz (e.g., 44100, 48000).

-c <channel_layout>
    Specifies the number of channels and their layout (e.g., 'mono', 'stereo', '5.1', '7.1').

-b <bit_rate>
    For lossy codecs (like AAC, MP3), sets the target bit rate in bits per second (e.g., 192000).

-q <quality>
    For lossy codecs, controls the encoding quality (0-127, where 127 is highest quality).

-s <sample_rate>
    An alias for -r, specifying the output sample rate.

-v
    Enables verbose output, showing more details about the conversion process.

-h
    Displays help information and usage syntax.

DESCRIPTION

The afconvert command is a powerful command-line utility primarily found on macOS, designed for converting audio files between various formats. It leverages Apple's Core Audio framework to provide robust capabilities for changing audio file containers (like AIFF, WAV, CAF, M4A) and encoding formats (such as PCM, AAC, MP3, FLAC, ALAC).

Users can specify precise output characteristics including sample rate, bit depth, channel layout, and encoding quality. While not a native Linux command, it is an essential tool for developers and users within the Apple ecosystem who need programmatic or batch audio conversion capabilities.

CAVEATS

The afconvert command is not a standard Linux utility. It is part of Apple's Core Audio Utility Kit and is natively available only on macOS (and iOS development environments).

Attempting to run afconvert directly on most Linux distributions will result in a 'command not found' error. Users on Linux needing similar functionality should instead use native Linux tools like ffmpeg or sox.

<B>COMMON USAGE EXAMPLE</B>

To convert an AIFF file to a 128 kbps AAC file within an M4A container:
afconvert -f mp4f -d aac\ -b 128000 input.aiff output.m4a
Note the two spaces after 'aac' in 'aac\ ' for the 4-char code, essential for correct parsing in some shells.

<B>UNDERSTANDING DATA FORMATS</B>

Many data formats for -d are 4-character codes (e.g., 'aac ', 'mp3 '). You can often find a full list in the Core Audio documentation or by using 'afconvert -h' on a macOS system, which sometimes lists supported format codes.

<B>PLATFORM SPECIFICITY</B>

Despite being queried in a Linux context, it is crucial to reiterate that afconvert is macOS-exclusive. It is not part of standard Linux distributions and cannot be run natively without a macOS environment or highly specialized emulation.

HISTORY

afconvert's history is deeply intertwined with Apple's development of its multimedia frameworks. It was introduced as part of the Core Audio framework, which debuted with macOS 10.0 (Cheetah) as OS X. As Apple's audio technologies evolved, so did afconvert, gaining support for new codecs (e.g., AAC, ALAC) and container formats. It has consistently served as the command-line interface for Core Audio's conversion capabilities, primarily for developers and power users within the Apple ecosystem.

SEE ALSO

ffmpeg(1), sox(1), mplayer(1)

Copied to clipboard