How to Inspect Audio File Metadata and Codec Properties on Mac Using afinfo

Determining the exact low-level technical specifications of digital audio files often leads Mac users to install bulky third-party media players or external GUI inspector utilities. However, macOS includes a high-performance, native command-line tool built into the Core Audio subsystem: afinfo (Audio File Info). Capable of reading virtually any format supported by Apple Core Audio—including AAC, ALAC, AIFF, WAV, MP3, FLAC, and CAF—afinfo instantly extracts bit rates, sample rates, channel configurations, packet counts, and ID3 or Apple metadata directly inside the Terminal.

Understanding afinfo and Core Audio Architecture

The macOS operating system handles multimedia processing through Core Audio, Apple’s low-latency, modular digital audio framework. Core Audio represents audio streams using strict technical structures known as AudioStreamBasicDescription (ASBD), which encapsulate sample rates, channel counts, bits per channel, bytes per packet, and codec flags.

The afinfo binary queries these underlying Core Audio structures directly from file headers without opening audio renderers or graphical players. This makes it an invaluable utility for audio engineers, developers, and system administrators who require instantaneous codec verification, automated audio quality auditing, or batch metadata inspection.

Running Basic Audio Inspections with afinfo

To inspect an audio file, open the Terminal application (found in /Applications/Utilities/Terminal.app) and execute afinfo followed by the path to the target audio file.

afinfo ~/Music/recording.m4a

The terminal will output a comprehensive technical breakdown structured as follows:

File:           /Users/admin/Music/recording.m4a
File type ID:   m4af
Num Tracks:     1
----
Data format:     2 ch,  48000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
                no channel layout.
estimated duration: 184.250000 sec
audio bytes: 3685000
audio packets: 8637
bit rate: 160000 bits / second
packet size upper bound: 768
maximum packet size: 642
audio data file offset: 4096
optimized

This output reveals key diagnostic metrics:

  • File type ID: The container format (for example, m4af for Apple MPEG-4 Audio, WAVE for Waveform, AIFF for Audio Interchange).
  • Data format: Number of channels (2 ch), sample frequency (48000 Hz), four-character codec code ('aac '), and frames per packet.
  • Estimated duration: Precise playback duration calculated down to fractional seconds.
  • Bit rate: Exact streaming transfer rate in bits per second (such as 160 kbps).
  • Optimized: Indicates whether the audio header and metadata atom (moov) are located at the beginning of the file for efficient web streaming.

Extracting Embedded Metadata and Tag Dumps

In addition to raw stream properties, audio files often store embedded metadata, including track titles, artists, album names, composer details, and encoder versions. The -m (or --metadata) flag instructs afinfo to read and display all user and system metadata dictionaries.

To inspect tags embedded in an MP3, AAC, or FLAC file, run:

afinfo -m ~/Music/track01.flac

The output appends a formatted list of all metadata keys detected inside the container:

metadata:
    title: Acoustic Symphony No. 4
    artist: Studio Ensemble
    album: High Resolution Sessions
    genre: Classical
    approximate duration in seconds: 320.125
    nominal bit rate: 921600

If an audio file contains album artwork, embedded lyrics, or encoder settings, afinfo -m exposes the corresponding Core Audio metadata keys without requiring external ID3 tag editors.

Generating Machine-Readable Property Lists (XML / Plist)

For developers and DevOps engineers building automated audio processing pipelines, parsing human-readable terminal output with regex is error-prone. The -x (or --xml) parameter forces afinfo to format its entire diagnostic report as a standard macOS XML property list (plist).

Execute:

afinfo -x ~/Music/podcast.wav

The output outputs well-formed XML:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>audio-bytes</key>
    <integer>44100000</integer>
    <key>channels</key>
    <integer>2</integer>
    <key>duration-seconds</key>
    <real>250.0</real>
    <key>sample-rate</key>
    <real>44100.0</real>
</dict>
</plist>

You can pipe this structured XML directly into plutil to extract specific keys instantly. For example, to query only the exact sample rate of an audio file:

afinfo -x ~/Music/podcast.wav | plutil -extract sample-rate raw -

The command outputs 44100 cleanly to stdout, making it effortless to write conditional logic in shell scripts.

Auditing Batch Audio Files in a Directory

When preparing large music libraries, sound effect banks, or video production assets, you frequently need to identify files that do not match project sample rate standards (such as 48 kHz for broadcast video).

Use a Bash loop combined with afinfo to audit an entire folder of audio assets:

for file in ~/Downloads/SoundEffects/*.wav; do
    echo -n "$(basename "$file"): "
    afinfo "$file" | grep -E "Data format|bit rate"
done

The loop rapidly prints the channel configuration, sample frequency, and bit rate for every file in the directory, allowing you to instantly identify 44.1 kHz files that need sample rate conversion before import.

Comparing Uncompressed vs Lossless vs Lossy Streams

The afinfo tool is especially useful for verifying whether a file is genuinely uncompressed PCM, lossless compressed (ALAC/FLAC), or lossy encoded (AAC/MP3).

Inspect the Data format line for the following signatures:

  • Linear PCM (WAV/AIFF): Shows 'lpcm' with explicit bits per channel (such as 16-bit little-endian signed integer).
  • Apple Lossless (ALAC): Shows 'alac' with 0 bytes/packet and dynamic frames per packet.
  • AAC: Shows 'aac ' with 1024 frames/packet.
  • MP3: Shows '.mp3' with 1152 frames/packet.

Mastering afinfo provides you with an instant, zero-dependency diagnostic toolkit directly within macOS Terminal, delivering complete insight into your digital audio library.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.