LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 09-17-2009, 09:51 AM   #1
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Rep: Reputation: 36
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
 
Old 09-17-2009, 10:31 AM   #2
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,771

Rep: Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283
I think that
Code:
mpg123 -t file.mp3
will do.

Regards
 
Old 09-18-2009, 12:02 AM   #3
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by bathory View Post
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
 
Old 09-18-2009, 12:11 AM   #4
bathory
Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 10,771

Rep: Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283Reputation: 1283
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
 
Old 09-18-2009, 01:51 AM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
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.
 
Old 09-18-2009, 09:34 AM   #6
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by slakmagik View Post
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 View Post
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
 
Old 09-18-2009, 09:50 AM   #7
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
Quote:
Originally Posted by bgoodr View Post
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.
 
Old 09-18-2009, 09:58 AM   #8
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
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
 
Old 09-18-2009, 10:04 AM   #9
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
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
 
Old 09-18-2009, 10:14 AM   #10
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,846

Rep: Reputation: 128Reputation: 128
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
                        }'

Last edited by pwc101; 09-18-2009 at 10:15 AM.
 
Old 09-18-2009, 11:06 AM   #11
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
midentify.sh works for me!

Quote:
Originally Posted by pwc101 View Post
... 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
 
Old 09-18-2009, 11:14 AM   #12
bgoodr
Member
 
Registered: Dec 2006
Location: Oregon
Distribution: RHEL[45] {x86,x86_64}, Debian "testing" {x86,x86_64}
Posts: 219

Original Poster
Rep: Reputation: 36
I posted a related question based upon my usage of mplayer at:
http://www.linuxquestions.org/questi...95#post3688695
 
Old 09-18-2009, 07:49 PM   #13
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 1,353

Rep: Reputation: 205Reputation: 205Reputation: 205
ffmpeg -i file.mp3

file file.mp3

mediainfo file.mp3

and probably dozens of other ways.
 
Old 09-18-2009, 10:23 PM   #14
jhwilliams
Senior Member
 
Registered: Apr 2007
Location: Portland, OR
Distribution: Debian, Android, LFS
Posts: 1,168

Rep: Reputation: 206Reputation: 206Reputation: 206
Quote:
Originally Posted by pwc101 View Post
s/[]()|&;<>`'"'"'\\!$" []/\\&/g;p
Gee. Can someone explain that substitution string to me?
 
Old 09-18-2009, 10:32 PM   #15
mrclisdue
Senior Member
 
Registered: Dec 2005
Distribution: Slackware -current, 14.1
Posts: 1,019

Rep: Reputation: 157Reputation: 157
Quote:
Originally Posted by jhwilliams View Post
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,
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to decrease the Bit Rate of MP3 files in Linux me4linux Linux - Software 6 08-11-2007 09:03 PM
MP2 to MP3. What bit rate? arubin General 5 05-25-2006 04:45 AM
increase mp3 bit-rate on old files Present Linux - Software 4 03-28-2005 10:35 PM
play audio mp3 files from command line? runlevel <5 carl0ski Linux - Software 3 12-02-2004 04:58 AM
Command line tool to print length of mp3 files? J_Szucs Linux - Software 3 05-04-2004 05:01 AM


All times are GMT -5. The time now is 11:21 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration