Ubuntu – How to find the bitrate of an mp3 file via command line

command linemp3

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?

Best Answer

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