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] infile [-o] outfile

PARAMETERS

-f fmt
    Specify output file format (e.g., aiff, caf, flac, m4a, wav)

-d type[#rate[#bps[#ch[#frames]]]]
    Output data format (e.g., lpcm, ima4, AAC 128kbps; rate in Hz, bps bits/sample, ch channels)

-o outfile
    Output file path; use - for stdout

-debug
    Enable verbose debugging output

-power
    Normalize peak amplitude to 1.0

-dither
    Apply dithering on truncation/rounding

-packetMode 0|1
    Variable (1) or constant (0) packet size for compressed formats

-q 0-127
    Quality level for VBR codecs like AAC

-s srcfmt
    Override source file format detection

-t key value
    Add metadata tag (e.g., ----:com.apple.iTunes:album)

-h
    Display help

-dataforkaudio
    Treat data fork as audio data (for Mac-specific files)

-useClipIfNeeded
    Clip audio if normalization exceeds limits

DESCRIPTION

afconvert is a powerful command-line utility for converting audio files between various formats supported by Apple's Core Audio framework. Primarily used on macOS, it handles file formats like AIFF, CAF, WAVE, AAC, FLAC, and more, while allowing precise control over output data formats such as LPCM, IMA4, or AAC with customizable sample rates, bit depths, and channels.

It supports metadata preservation, dithering for quality, normalization, and advanced features like packet mode for compressed formats. Ideal for batch processing, format transcoding without quality loss in lossless cases, or preparing audio for specific devices. Note: While invoked as a Linux command here, it is native to macOS; Linux users may need emulation or alternatives like FFmpeg.

CAVEATS

Native to macOS (Core Audio); unavailable on standard Linux without emulation (e.g., via Darling). Use FFmpeg or SoX as Linux alternatives. Some formats require specific codecs.

COMMON DATA FORMATS

Examples: lpcm (uncompressed), alac (lossless), aac 64000 (VBR), ULEAD (IMA ADPCM). Append @44100 for 44.1kHz, @16 for 16-bit, @2 for stereo.

EXAMPLE USAGE

afconvert -f WAVE -d LEI16@44100 input.aiff output.wav
Converts AIFF to 16-bit WAV at 44.1kHz.

HISTORY

Introduced in Mac OS X 10.3 (Panther) as part of Core Audio; evolved with support for modern formats like AAC and FLAC in later versions. Maintained by Apple for pro audio workflows.

SEE ALSO

ffmpeg(1), sox(1), lame(1)

Copied to clipboard