dcsimg

Command Line Audio: Simple as mpg123

Your mileage may vary with mpg123 but your MP3 listening enjoyment never will.

Did you ever want a little background music with your daily grind but either you didn’t want to (or couldn’t) fire up something graphical to use? That’s where mpg123 comes to your rescue. Mpg123 is a fast console MPEG audio player and decoder library. If you’re about to click on to another story because you think that a command line music playing application is devoid of features or functions, you’re going to miss out on one of the coolest and most versatile MP3 applications you’ve ever seen.

Those of you who work most of your 50-hour plus weeks at the command line deserve the same multimedia enjoyment that your GUI-tethered coworkers enjoy. Applications such as mpg123 give you the opportunity to get real work done and have a little fun while you do.

The Basics

It’s simple to install mpg123. You only need simple typing skills to install this command line gem.

$ sudo apt-get install mpg123

or,

$ sudo yum install mpg123

For purists or those less fortunates who have no packaged mpg123 version, you can download the source code is at http://sourceforge.net/projects/mpg123/.

Taking mpg123 for a Test Drive

Though mpg123 is small in stature, it could take 30 minutes or more to install it. It takes so long because, during the installation and setup process, the program automatically downloads sample podcasts into your home directory under a new directory named POD. Under that directory you’ll see the following directories: Linux, LINUX and Privacy. In each of those directories, you have directories that are home to three specific podcasts: The Privacy Podcast, The Linux Link and LUG Radio. For the purposes of this article, I chose the Privacy Podcast, by Aaron Titus, titled “When Breaches Go Unreported” due to its excellent and serious content. You should definitely listen to this one for your own edification.

To play one of the downloaded podcasts or a music file that you’ve purchased legally, summon mpg123 at the command line and use the -C switch to invoke mpg123′s full control complement.

$ mpg123 -vC POD/Privacy/Privacy\ Podcast/privacy-2007-10-22-56442.mp3

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

Terminal control enabled, press 'h' for listing of keys and functions.

Playing MPEG stream 1 of 1: privacy-2007-10-22-56442.mp3 ...
Title:   When Breaches Go Unreported     Artist: Aaron Titus
Comment: Join Aaron Titus and explore common threats to your identity, and practical advice on how to make your identity more secure. www.aarontitus.net/privacy/
Album:   The Privacy Podcast
Year:    2007                            Genre:  Privacy
MPEG 1.0, Layer: III, Freq: 44100, mode: Stereo, modext: 0, BPF : 418
Channels: 2, copyright: No, original: No, CRC: No, emphasis: 0.
Bitrate: 128 kbit/s Extension value: 0
Frame#   768 [15040], Time: 00:20.06 [06:32.88], RVA:   off, Vol: 100(100)

The podcast begins to play for you. This one is just under seven minutes in length. The ‘-v’ switch provides a verbose output that shows you the Channel information, bitrate, counter and volume settings. To see mpg123′s controls, type ‘h’ during playback. Doing so will show the menu of available controls displayed below.

 -= terminal control keys =-
[s]     or [ ] interrupt/restart playback (i.e. '(un)pause')
[f]     next track
[d]     previous track
[b]     back to beginning of track
[p]     loop around current position (like a damaged audio CD;-)
[.]     forward
[,]     rewind
[:]     fast forward
[;]     fast rewind
[>]     fine forward
[<]     fine rewind
[+]     volume up
[-]     volume down
[r]     RVA switch
[v]     verbose switch
[l]     list current playlist, indicating current track there
[t]     display tag info (again)
[m]     print MPEG header info (again)
[h]     this help
[q]     quit
[c]     or [C] pitch up (small step, big step)
[x]     or [X] pitch down (small step, big step)
[w]     reset pitch to zero

If you have a directory that contains your favorite songs, you can play them all by issuing the mpg123 command with a wildcard setting.

$ mpg123 -vC *.mp3

Remote Access

If you must connect to your MP3 library remotely, don’t despair; you can listen as if you had direct access to the system console. From your local system, ssh to the remote system and issue the mpg123 command to enjoy your audio gold just as you would from the console. This feature comes in handy for those of you who can connect remotely to a home-based Linux system that has all your MP3s, leaving your work computer untouched by any “foreign” files that could score you a reprimand (or worse) from those who dispense your paycheck.

The mpg123 project maintainers provide regular updates though the documentation could use some help. Your best source for information on it is through its man page. You can get a lot of mileage out of mpg123 but beyond the basics, you’re on your own. For those of you so inclined, contact the developers to enhance and expand the documentation for this incredibly simple, fast and flexible utility.

Comments on "Command Line Audio: Simple as mpg123"

leamanc

I first fell in love with mpg123 when I got Ubuntu 5.x or 6.x (I forget which) up and running on a 400 MHz G4 Cube. Remember, this was a lifetime ago in Linux terms; PowerPC has never been a great platform for desktop Linux; and Ubuntu (although the best Linux option for my Cube) was nowhere near as smooth as it is now.

On this setup, even bare-bones music players like Rhythmbox had a hard time keeping up with playing audio files of any kind if I wanted to do anything else with the computer. Skipping, stuttering, and other annoyances were the norm.

On a whim, I searched Synaptic for a command-line MP3 player, and found mpg123. It was great! It played my music in the background, the interface was super-easy to learn, and being a CLI app, it was scriptable! I wrote all kinds of quick-and-dirty bash scripts to start music playing when I sat down at the computer, did cool things like build playlists from text files, set up a shuffle mode, etc. It was good geeky fun, but the best part was I had music while browsing in Firefox on that creaky old box. :-)

Sadly, I haven’t used mpg123 since I retired the Cube, but I will always have fond memories of it.

Reply
shreedhan

How is this different from mplayer in command line ?

Reply
gillbates

At my previous work, we installed a PHP web-based mp3 jukebox on our development server. The backend used mpg123, I think.

Reply
curmudgeonbob

cmus is not limited to mp3 files and just as easy to use.

Reply
killerb

Beside cmus I can definitely recommend MOC (Music On Console)
It is designed to be powerful and easy to use, with a command structure and window layout similar to the Midnight Commander console file manager.
Supported file formats are: mp3, Ogg Vorbis, FLAC, Musepack, Speex, WAVE, AIFF, AU (and other less popular formats supported by libsndfile.

Cheers

Reply

I want to convert text to speech with mpg123. Can I use this program and how to use that?
THank you for your answer :)

Reply

    You cannot convert text to speach using mpg123, for that purpose, use a good
    speech synthesis engine like festival or eSpeak

    Reply

    To make TTS with 123MPG, you can just use a google service as the sound source. Here is the simplest example (speaking in french, as required by the parmeter “q=”:

    mpg123 “http://translate.google.com/translate_tts?tl=fr&q=\”Bonjour Laurence, comment va-tu ?\”"

    Enjoy !

    Franck

    Reply

I appreciate you sharing this blog.Much thanks again. Want more.

Reply

Say, you got a nice blog post.

Reply

I simply could not depart your site prior to suggesting that I actually loved the standard information a person supply in your visitors? Is gonna be back regularly to check up on new posts

Reply

Does your site have a contact page? I’m having trouble locating it but, I’d like to shoot you an email. I’ve got some creative ideas for your blog you might be interested in hearing. Either way, great blog and I look forward to seeing it grow over time.

Reply

I’m not sure why but this blog is loading extremely slow for me. Is anyone else having this problem or is it a issue on my end? I’ll check back later on and see if the problem still exists.

Reply

Very good written story. It will be valuable to everyone who utilizes it, as well as myself. Keep doing what you are doing – i will definitely read more posts.

Reply

Keep functioning ,remarkable job!

Reply

I must get across my admiration for your generosity giving support to women who must have help with the area of interest. Your real commitment to passing the solution all over was exceedingly powerful and has in most cases permitted individuals just like me to arrive at their ambitions. The helpful report signifies a great deal to me and much more to my office colleagues. Many thanks; from all of us.

Reply

I cling on to listening to the newscast speak about getting free online grant applications so I have been looking around for the most excellent site to get one. Could you advise me please, where could i get some?

Reply

You could definitely see your skills in the work you write. The world hopes for more passionate writers like you who aren’t afraid to say how they believe. Always follow your heart.

Reply

I would like to thnkx for the efforts you have put in writing this web site. I am hoping the same high-grade site post from you in the upcoming also. Actually your creative writing abilities has inspired me to get my own site now. Actually the blogging is spreading its wings rapidly. Your write up is a great example of it.

Reply

Thank you one million and please carry on the rewarding

Reply

I am always searching online for articles that can assist me. Thank you!

Reply

PipncS You need to participate in a contest for the most effective blogs on the web. I all recommend this site!

Reply

Awesome post. I am a normal visitor of your website and appreciate you taking the time to maintain the nice site. I will be a frequent visitor for a really long time.

Reply

The time to study or stop by the content material or sites we have linked to beneath.

Reply

We prefer to honor quite a few other internet web-sites around the net, even if they aren?t linked to us, by linking to them. Below are some webpages really worth checking out.

Reply

One of our guests a short while ago suggested the following website.

Reply

We came across a cool web site which you could appreciate. Take a search should you want.

Reply

Every when in a when we choose blogs that we read. Listed below are the most up-to-date sites that we select.

Reply

Every the moment inside a though we opt for blogs that we read. Listed beneath would be the latest sites that we select.

Reply

Wonderful story, reckoned we could combine some unrelated information, nonetheless definitely really worth taking a look, whoa did a single learn about Mid East has got more problerms also.

Reply

Please visit the web-sites we stick to, like this 1, as it represents our picks through the web.

Reply

Just beneath, are several totally not connected web pages to ours, nevertheless, they are certainly worth going over.

Reply

Always a huge fan of linking to bloggers that I really like but really don’t get a lot of link love from.

Reply

Sites of interest we’ve a link to.

Reply

Here are some links to websites that we link to since we believe they’re really worth visiting.

Reply

Sites of interest we have a link to.

Reply

Awesome post. I am a regular visitor of your blog and appreciate you taking the time to maintain the excellent site. I will be a regular visitor for a really long time.

Reply

Thanks for the sensible critique. Me and my neighbor were just preparing to do a little research about this. We got a grab a book from our local library but I think I learned more clear from this post. I’m very glad to see such wonderful information being shared freely out there.

Reply

Always a large fan of linking to bloggers that I like but really don’t get a great deal of link adore from.

Reply

I like this web site so much, bookmarked. “Nostalgia isn’t what it used to be.” by Peter De Vries.

Reply

Although websites we backlink to below are considerably not associated to ours, we really feel they are actually really worth a go as a result of, so possess a look.

Reply

Every after in a when we choose blogs that we read. Listed below are the most current web-sites that we pick out.

Reply

We prefer to honor many other world-wide-web sites around the web, even if they aren?t linked to us, by linking to them. Beneath are some webpages worth checking out.

Reply

Always a major fan of linking to bloggers that I love but do not get lots of link adore from.

Reply

You ought to be a part of a contest for one of the greatest sites on the internet. I will highly recommend this web site!

Reply

Please go to the internet sites we follow, which includes this one, because it represents our picks through the web.

Reply

We came across a cool web page which you may delight in. Take a look should you want.

Reply

The information and facts mentioned inside the write-up are a few of the very best offered.

Reply

We came across a cool web page that you just could possibly get pleasure from. Take a appear in case you want.

Reply

Wonderful story, reckoned we could combine some unrelated data, nonetheless definitely worth taking a look, whoa did a single discover about Mid East has got far more problerms also.

Reply

Although internet websites we backlink to beneath are considerably not connected to ours, we feel they may be truly really worth a go through, so possess a look.

Reply

Here are some hyperlinks to internet sites that we link to for the reason that we consider they may be really worth visiting.

Reply

The time to read or stop by the material or web sites we have linked to below.

Reply

Here are a few of the internet sites we advocate for our visitors.

Reply

Every once in a when we select blogs that we read. Listed below would be the most current web pages that we decide on.

Reply

Every the moment in a even though we pick out blogs that we read. Listed below would be the most current internet sites that we opt for.

Reply

Wonderful story, reckoned we could combine a couple of unrelated data, nonetheless actually really worth taking a look, whoa did one particular learn about Mid East has got extra problerms at the same time.

Reply

That may be the end of this article. Here you?ll discover some web pages that we believe you will value, just click the hyperlinks.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>