afinfo - macOS


afinfo (Audio File Info) is a command-line utility on macOS that provides detailed information about audio files. It’s primarily used to display audio file metadata and properties such as file format, duration, sample rate, and more. This tool is invaluable for audio engineers, developers, and enthusiasts who need to inspect audio file details or troubleshoot issues related to audio files.


To use afinfo, the basic syntax is:

afinfo [option] file

Here, file is the path to the audio file you want to analyze.


  • -b: Display a brief one-line description of the audio file. Useful for scripting or when only basic format information is needed.
  • -r: Shows additional format-specific information that is not part of the core audio stream but may be present in the file.
  • -x: Generate output in XML format. This is helpful for integration with other tools or when processing the output programmatically.

Each flag modifies the output detail and format, catering to different use cases, from quick summaries to in-depth, programmatic analysis.


  1. Basic Usage:
    Get detailed information about an audio file:

    afinfo example.mp3
  2. Brief Information:
    Get only a one-line description of the file:

    afinfo -b example.mp3
  3. Output in XML Format:
    Get detailed information in XML format for programmatic use:

    afinfo -x example.mp3

Common Issues

  • Unsupported File Formats: afinfo might fail to provide details if the audio file format is not supported. Ensure the file is in a compatible format like .mp3, .wav, or .m4a.
  • Incorrect File Paths: If the specified file path is incorrect, afinfo will not be able to locate the file. Double-check the file path.
  • Permission Issues: If the file is not readable due to permissions, afinfo will fail. Ensure you have the appropriate permissions to access the file.


afinfo can be combined with other commands like grep for more refined searches or conditional scripting:

# Extract and check the sample rate of a file
sample_rate=$(afinfo example.mp3 | grep "Sample Rate" | awk '{print $3}')
if [ "$sample_rate" -ne "44100" ]; then
    echo "Unexpected sample rate: $sample_rate Hz"
  • audiodevice: A command to manage and control audio devices.
  • afconvert: A command-line utility to convert audio file formats, sample rates, and more on macOS.

For further reading and detailed documentation about macOS audio tools, visit the Apple Developer Documentation.