How to Use Afinfo to Get Audio Info on Mac
Afinfo is a little utility developed by Apple. You can use it to view audio file information from the command line in macOS. In this article, we will use an mp3 file as an example to show how you can view its file details. Mp3s are the most popular audio format that works on most devices. If you want to see the technical metadata about your mp3 files, you can do that using Terminal on your Mac. We will use the afinfo command; afinfo stands for Audio File Info. Again, I should say that although this article focuses on Mp3, the same steps will work on any other audio formats as well.
By following the steps below, you can obtain information on your file’s audio properties, such as bytes, packets, bitrate, number of channels and more. Here is how:

Use afinfo to get details
1. Open Terminal. The Terminal app is located in the Utilities folder.
2. Now, we will need to enter the command to view the mp3 file info. First, you will need to figure out the path to the audio file. If you do not know the path, you can right-click (or Control-click) the mp3 file in Finder and then select Get Info. You will see the file’s path.

3. After finding the path, our command format will be like this:
afinfo PATH/To/File.mp3
I have an mp3 file in my Downloads folder named macreports.mp3. Thus my exact command will be:
afinfo ~/downloads/macreports.mp3
4. After entering the command, hit Enter. Then Terminal will produce a series of information like this:
Last login: Tue Dec 6 18:54:04 on ttys000
serhatkurt@Serhats-MacBook-Pro ~ % afinfo ~/downloads/macreports.mp3
File: /Users/serhatkurt/downloads/macreports.mp3
File type ID: MPG3
Num Tracks: 1
----
Data format: 2 ch, 44100 Hz, .mp3 (0x00000000) 0 bits/channel, 0 bytes/packet, 1152 frames/packet, 0 bytes/frame
no channel layout.
estimated duration: 48.666187 sec
audio bytes: 778659
audio packets: 1863
bit rate: 128000 bits per second
packet size upper bound: 1052
maximum packet size: 418
audio data file offset: 4096
optimized
----
serhatkurt@Serhats-MacBook-Pro ~ %
Afinfo options
The afinfo command also includes several options. You can view these options again using Terminal. Simply type afinfo
in Terminal and hit Enter, and you will see all of the options like this:
Last login: Tue Dec 6 19:03:01 on ttys000
serhatkurt@Serhats-MacBook-Pro ~ % afinfo
Audio File Info
Version: 2.0
Copyright 2003-2016, Apple Inc. All Rights Reserved.
Specify -h (-help) for command options
Usage:
afinfo [option...] audio_file(s)
Options: (may appear before or after arguments)
{-h --help}
print help
{-b --brief}
print a brief (one line) description of the audio file
{-r --real}
get the estimated duration after obtaining the real packet count
{ --leaks }
run leaks at the end
{ -i --info }
print contents of the InfoDictionary
{ -u --userprop } 4-cc
find and print a property or user data property (as hex string) [does not print to xml]
{ -c --chunkdata } 4-cc
find and print a chunk (as hex string) [does not print to xml]
{ -x --xml }
print output in xml format
{ --warnings }
print warnings if any (by default warnings are not printed in non-xml output mode)
serhatkurt@Serhats-MacBook-Pro ~ %
As you can see above, you can customize your command to modify the output. For example, if you want the output in XML format, then you will use the -x option; your command would look like this:
afinfo -x ~/downloads/macreports.mp3
Once you hit Enter, Terminal will show the file info in XML format.
Related articles