# How to find the bitrate of an mp3 file via command line?

What is the terminal command that can used to find the bitrate of an mp3 file?

Is there any other option available other than mpg321 -t name.mp3?

-

Simply put:

file song.mp3


Note: file is included with Ubuntu.

For alias lovers, insert this at the end of your ~/.bashrc file:

bitrate () {
echo basename "$1": file "$1" | sed 's/.*, $$.*$$kbps.*/\1/' | tr -d " "  kbps
}


Open a new Terminal window. You may now run the following command:

bitrate song.mp3

-
wow. Simple file command did the trick. –  devav2 Oct 5 '12 at 19:32
Be warned: if the file is variable bit rate (VBR), file will report only the one of the many bit rates present. (I think it's the first frame's bit rate.) The answer could be deceptive if most of the file is at a very different rate. If you want to know the average bit rate, see apacheuk's answer. –  Alan De Smet Feb 5 '14 at 4:44

Install mp3info package

sudo apt-get install mp3info


To find the bitrate use

mp3info -r a -p "%f %r\n" *.mp3


will give the info you need, also has some other useful functions man mp3info for more info

-
mp3info does not support ID3v2 tagging. –  Ian Sep 13 '13 at 17:15

MediaInfo is further solution to do that (not only on mp3).

sudo apt-get install mediainfo


Example:

mediainfo Aphrodite_-_Superman_$$dnb$$.mp3 | grep "Bit rate"


Output:

Bit rate mode                            : Constant
Bit rate                                 : 192 Kbps


Another Example:

mediainfo Aphrodite_-_Superman_$$dnb$$.mp3 | grep 'Bit rate  '


Another Output:

Bit rate                                 : 192 Kbps

-

You can install the package libimage-exiftool-perl:

sudo apt-get install libimage-exiftool-perl


Then run:

exiftool -AudioBitrate GoldLion.mp3


It will output something like:

Audio Bitrate : 192 kbps

-
Cool! This provides wonderful meta information about the file. –  devav2 Oct 5 '12 at 19:30