July 06, 2008

13 Command Line Tools for Audio on Linux

cmus
cmus is a music player using the ncurses interface, with a Vi-style of maneuvering it. For example, you will type :a ~/music/ to add directory ~/music/ to the playlist, and :q to quit.

For those who like the Vi editor, cmus will probably make a great CLI audio player

ogg123
Official Ogg Vorbis player included in the vorbis-tools package, this nice command line player will also read Vorbis tags and play your audio files encoded as Vorbis.

mpg123
This is the well-known command line MP3 player.

oggenc
Official tool from xiph.org capable of encoding from FLAC or WAV to Ogg Vorbis. It takes many options as arguments, like bitrate or quality.

flac
flac will encode and decode FLAC files (Free Lossless Audio Codec), and also convert FLAC to WAV and vice-versa. It has many parameters available and you can also select the compression level. FLAC is a format which lately got popular since it offers lossless audio quality at lower compression sizes than WAV, and it's completely free.

vorbiscomment
Included in the vorbis-tools package, this tool allows to edit or remove any tag(s) from an Ogg Vorbis file. You can also add any tag name and value. I use this in scripts to perform several edits on tags, like the one below, which clears all the tags in an Ogg Vorbis file:

#!/bin/bash

echo "OGG Tag Remover"
echo "Creating empty file..."
touch file

echo "Starting to remove all tags in OGG files..."
for i in *.ogg; do
echo "Executing command 'vorbiscomment -w \"$i\" -c file'..."
nice -n 15 vorbiscomment -w "$i" -c file
done

echo "Removing empty file..."
rm file

echo "Done! All tags removed."

cuebreakpoints
Used together with shnsplit, cuebreakpoints helps you split FLAC or WAV files according to a CUE file.

shnsplit
From the manual page, shnsplit "is a command‐line utility to view and/or modify WAVE data and properties". Use it with cuebreakpoints to split WAV or FLAC files like this:

cuebreakpoints audio_file.cue | shnsplit audio_file.flac

mp3blaster
mp3blaster is a popular MP3 and Vorbis player with a TUI (Text User Interface).


ogginfo
Shows detailed information about Ogg files.


mpd
The Music Player Daemon is a server that allows to play audio files, like FLAC, MP3, Ogg Vorbis, WAV and AIFF. You will also need a client, like mpc for CLI or Sonata for GUI.

ripit
According to the manual page, ripit is a 'Perl script to create .flac .ogg .mp3 or .m4a (aac) files from an audio CD.'

music123
music123 is a CLI audio player which can play Ogg, MP3, WAV and it behaves pretty much like mpg123 or ogg123.

Conclusion
As a conclusion, you may ask if these are really useful considering there are so many good-looking and full-featured GUI audio players out there. Well, yes, they are! I use oggenc, ogginfo and flac all the time, I like those over any GUI frontend. mpd can prove very useful for those who like to have a music server on their own PC or remotely connect to it from another. mp3blaster is just great if you want to use less resources, and eventually leave the player somewhere in a console window. As for mpg123 and ogg123, well I used those heavily in the past on an old AMD K6/2 with Debian 3.1, when I used to work a lot only in command line, without starting the X Window System.

Not to mention frontends like soundKonverter, where those powerful tools are used for encoding/decoding and converting between formats.

Here is a tutorial I wrote on how to use flac, oggenc, shnsplit, cuebreakpoints and vorbiscomment for manipulating audio files.

Updated: Jul 07, 2008 (Created: Jul 06, 2008)

19 comments:

Heso said...

And you still missed some of them. :)

cdparanoia is probably the best CD ripper around and is used by many of the GUI rippers.

SoX is a package with a LOT of useful tools in it, including conversions between audio formats and a player (the "play" command).

streamripper is the best ripper from online radios.

mplayer can be used very well as a console audio player. But you need to pick up some tricks to make it play nice. For instance:

cd /home/user/music
find *.mp3 | mplayer -shuffle -playlist - < /dev/null


This will go to your music directory, find all MP3 files in all subdirs and play them in random order. Replace "find *.mp3" with "ls" to play files just from the current dir.

Dan Craciun said...

Thanks again, heso :)

I'll make several additions with those good suggestions. I don't think I'll include mplayer though, but the others are great.

Darren said...

ffmpeg can do some awesome conversions and splitting. Here's the command I use to make ringtones out of mp3s:

ffmpeg -i in.mp3 -ss 38 -t 20 -ab 320 out.mp3

ss=starting point
t=duraion
ab=bitrate

Anonymous said...

I reckon abcde is excellent. It ties together a whole bunch of other utilities (some of which already got a mention) to do ripping, CDDB lookups and encoding.

saperduper said...

You missed cplay!
Cplay is a frontend for various audio players. It provides a power-user-friendly interface with simple filelist and playlist control.

http://directory.fsf.org/project/cplay/

Anonymous said...

Regarding mpd, you misspoke about clients. Clients for mpd include say, mpc for command-line control, or beautiful GUI clients like Sonata.

XMMS2 is a competing project to mpd. Very similar in concept, it's more featureful, and I've just made the switch.

Either music player is a godsend if you're a person who bounces in and out of X often.

Dan Craciun said...

I guess I rushed into that one, thanks for pointing out.

fwiffo said...

You forgot also moc ("Music On Console" - http://moc.daper.net) which I prefer even to most gui ones.

Cheers

Heso said...

Oh, I remembered two more! :) When darren mentioned ringtones I remembered beep, which uses the PC Speaker to create tones of any lenght and frequency. And the connection is that at some point I saw a shell script that could play Erricsson ringtones using beep. :) Can't find it again though and anyway nowadays most mobiles use MP3's, but it was funny.

And then there's mikmod which can play pretty much any tracker music, and there's still a LOT of tracker music out there, see modarchive.org for example.

Dan, don't bother adding all the suggestions to the post, just let people add them. I suspect there's gonna be more than you can keep track of anyway. :)

Dan Craciun said...

Ok, that's cool then :-)

Anonymous said...

I support Linux 100% but I feel that the current audio apps are a bit behind of what you can get under mac and/or windows.

People should make an objective decision for themselves after reading The Truth about Linux.

Anonymous said...

And even more great command line utilities:

mpgedit - fastest mp3 editor, Has a curses, X as well as a command line interface.

dekagen - great bash script mp3 ripper front end.

Matelot said...

uummm WHY ???? Why playing music via command line ???????

Anonymous said...

Are there any command line programs that will remove silence from the begining of an mp3? I know sox will do this with wav files, but I need to do this on mp3s.

Anonymous said...

I use cutmp3 for removing silence from the beginning and end of mp3s.

Anonymous said...

Awesome! Was looking forever for something like that...thanks!

Seth said...

Any of these able to be used on a web server and dump files to a directory for download?

Looking for a server side audio manipulation tool for *nix server if anyone knows of any. Thanks.

lukeskibinski said...

ncmpc! The best command line client for mpd, or any music player, I've ever used. Once you have the shortcuts down (really simply ones), it's wonderful to use.

Anonymous said...

Very Nice information

BR,
Gokul
http://gokulkartha.blogspot.com