How to Play Ogg Vorbis Files from the Linux Command Line

HeadphonesIf you’re a dedicated user of free and open source software, chances are your dedication goes beyond just software. You probably try to use as many open file formats as you can. Document formats, video formats, and audio formats. Especially audio formats.

In the world of free and open source software, a popular format is Ogg Vorbis. Ogg Vorbis offers comparable audio quality and file compression as MP3, but without all the potential hassles the come from the patents that apply to MP3.

Just about every free and open source desktop media player supports Ogg Vorbis. But what if you want a player that’s a little lighter, or are using a stripped-down Linux distribution on an older, underpowered computer? The obvious answer: turn to the command line.

Using a command line application called ogg123, you can play back your Ogg Vorbis files without a lot of overhead.

Installing ogg123

ogg123 isn’t a standalone application. It’s part of a package called vorbis-tools. vorbis-tools comes pre-installed with a number of Linux distributions. To find out if it’s installed in yours, open a terminal window and type the following command:

which ogg123

If the command returns something like the following (/usr/bin/ogg123 in this example), then you’re ready to go.
Is ogg123 installed?

Otherwise, you need to install vorbis-tools. You can do that using your favorite package manager. If vorbis-tools isn’t available, then you can download and install it manually.

Using ogg123

Open a terminal window and change to the directory containing the files that you want to play. Then type the command ogg123 *.oga. This will play all of the files in the directory, in order.

That’s not very exciting, is it? If you want to shuffle the tracks to play them randomly, then type ogg123 -z *.oga.

Playing an Ogg Vorbis file

If you’ve ripped songs off of a CD, chances are the ripping process created a playlist file (with the extension .m3u). You can use that with ogg123 by typing the command ogg123 -@ playlist.m3u, substituting the actual name of the file for playlist.

To jump to the next track, press CTRL+C on your keyboard.

Note that ogg123 has a number of options. You can view them by typing ogg123 at the command line or viewing this reference.

Dealing with Cover Art

Music files, no matter what their formats, contain a number of tags. These tags include the title of the track, the name of the album, the artist, and the like. One of the tags also points to cover art. When you play the file in a graphical music player, an image of the album’s cover appears in the player.

If an Ogg Vorbis file you’re playing with ogg123 contains the cover art tag, ogg123 will try to render the art. However, you won’t get the image. Instead, you’ll get a stream of numbers and letters, like this:

Trying to render cover art. Not pretty!

There’s no way to suppress this, sorry.

Summing Up

ogg123 is a simple yet effective media player for the Linux command line. It’s easy to use and does a very good job. It has one or two small quirks, but those are easy to ignore. In fact, once you start using ogg123 you might just wind up using it instead of your favorite GUI music player.

Photo credit: celiece