LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to show bit-rate on mp3 files from the command line? (https://www.linuxquestions.org/questions/linux-software-2/how-to-show-bit-rate-on-mp3-files-from-the-command-line-755923/)

bgoodr 09-17-2009 09:51 AM

How to show bit-rate on mp3 files from the command line?
 
Sometime in the past, I had installed some Debian package that would show the bit-rate on a .mp3 file, but alas, I cannot remember the name of the package. I thought it was the id3v2 utility, but that does not apparently show the bit-rate. I installed mpg123, but the mpg123 man page says nothing about showing that type of info. I do not want a GUI, I need it from the command line.

Can someone tell me what package I can install to show the bit-rate (no, I don't want to build it from source if at all possible), and ideally it would show it along with the ID3v2 MP3 tags as well similar to what id3v2 does.

Thanks,
bgoodr

bathory 09-17-2009 10:31 AM

I think that
Code:

mpg123 -t file.mp3
will do.

Regards

bgoodr 09-18-2009 12:02 AM

Quote:

Originally Posted by bathory (Post 3687106)
I think that
Code:

mpg123 -t file.mp3
will do.

Yes, that does show the bitrate, but takes way to long to come back with the answer on long mp3 files, presumably since that -t option decodes the entire stream file. I am expecting to be able to be able to get a bitrate reading from many .mp3 files, and that delay will be too expensive. So, aren't there any other tools that just seek into the file and read out the bitrate along with the other tags?

Thanks,
bg

bathory 09-18-2009 12:11 AM

In that case, you can use the the -n option (number of frames):
Code:

mpg123 -t -n 1 file.mp3
I'm not aware of other CLI tools.

Regards

slakmagik 09-18-2009 01:51 AM

id3info (which is a sort of demo tool in id3lib) will give you the bit rate and tags but only id3v1. There's also id3, mp3info, the aforementioned id3v2, and several others. I can't remember which are which and do what, though.

bgoodr 09-18-2009 09:34 AM

Quote:

Originally Posted by slakmagik (Post 3688141)
id3info (which is a sort of demo tool in id3lib) will give you the bit rate and tags but only id3v1. There's also id3, mp3info, the aforementioned id3v2, and several others. I can't remember which are which and do what, though.

Quote:

Originally Posted by bathory (Post 3688072)
In that case, you can use:
Code:

mpg123 -t -n 1 file.mp3
Regards

Thanks everyone. I'll give them a shot and report back what I find that works the best.

bg

bgoodr 09-18-2009 09:50 AM

Quote:

Originally Posted by bgoodr (Post 3688597)
Thanks everyone. I'll give them a shot and report back what I find that works the best.

bg


I found some of my files that, when running both with "mpg123 -t -n 1" and "mpg123 -t", I see output of the form that does NOT include any kbit/s reading:

Code:

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
    version 1.7.2; written and copyright by Michael Hipp and others
    free software (LGPL/GPL) without any warranty but with best wishes

Directory: [CENSORED]
Playing MPEG stream 1 of 1: [CENSORED] ...
Title:  [CENSORED]                      Artist: [CENSORED]
Comment:                                Album:  [CENSORED]
Year:    2007                            Genre:  Jazz,
MPEG 1.0 layer III, VBR, 44100 Hz joint-stereo

[0:00] Decoding of [CENSORED] finished.

So I don't know why that would be the case since the files do have to have some bitrate, don't they? Regardless, I'll investigate the other programs that were suggested.

bgoodr 09-18-2009 09:58 AM

Testing the id3 package
 
The id3 program only shows the id3 tags, not the bit rate (unless there is some undocumented option not shown in the id3 man page).

Trying the other suggested tools ...


bg

bgoodr 09-18-2009 10:04 AM

Testing the mp3info package
 
mp3info is not id3v2 aware, resulting in this error message:

Code:

<file> does not have an ID3 1.x tag.
bg

pwc101 09-18-2009 10:14 AM

I've not got time to test it, but I seem to recall that the midentify.sh script that's in the mplayer source archive might be able to give you this information.

edit: Here it is:
Code:

#!/bin/sh
#
# This is a wrapper around the -identify functionality.
# It is supposed to escape the output properly, so it can be easily
# used in shellscripts by 'eval'ing the output of this script.
#
# Written by Tobias Diedrich <ranma+mplayer@tdiedrich.de>
# Licensed under GNU GPL.

if [ -z "$1" ]; then
        echo "Usage: midentify.sh <file> [<file> ...]"
        exit 1
fi

mplayer -vo null -ao null -frames 0 -identify "$@" 2>/dev/null |
        sed -ne '/^ID_/ {
                          s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p
                        }'


bgoodr 09-18-2009 11:06 AM

midentify.sh works for me!
 
Quote:

Originally Posted by pwc101 (Post 3688632)
... midentify.sh script ...

Thanks a bunch everyone. the midentify.sh script fits the bill I believe, but I will have to try it on tons of files first. Some of the files I tried it on show two outputs for bitrate which I will have to puzzle over.

Again, thanks everyone!
bg

bgoodr 09-18-2009 11:14 AM

I posted a related question based upon my usage of mplayer at:
http://www.linuxquestions.org/questi...95#post3688695

Shadow_7 09-18-2009 07:49 PM

ffmpeg -i file.mp3

file file.mp3

mediainfo file.mp3

and probably dozens of other ways.

jhwilliams 09-18-2009 10:23 PM

Quote:

Originally Posted by pwc101 (Post 3688632)
s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p

Gee. Can someone explain that substitution string to me?

mrclisdue 09-18-2009 10:32 PM

Quote:

Originally Posted by jhwilliams (Post 3689258)
Gee. Can someone explain that substitution string to me?

I'm pretty sure that it defines the author as a virgo, with libra on the horizon, then you turn left, go down three flights of stairs, take the elevator up 6 floors, to the lingerie department, look up, flick your left ear, leave via the fire exit, hail the 3rd burgundy cab that comes your way, and tell the driver to "fondle mine botox", or something eerily similar.

hth,


All times are GMT -5. The time now is 10:51 AM.