59

What are popular audio players for the command line?

  • How to play a single sound file?
  • Are there command line players that also index the music library like Banshee, Exaile, etc.?
Rinzwind
  • 293,910
  • 41
  • 570
  • 710
type
  • 3,227
  • 5
  • 31
  • 45

15 Answers15

38

I have compiled a complete list of commandline and other lightweight tools for linux: Best Lightweight Applications for Linux. It also has a list of other music players.

Here is my personal favorite: cmus.

cmus

David Foerster
  • 35,754
  • 55
  • 92
  • 145
hsinxh
  • 3,190
  • 2
  • 25
  • 30
  • Thanks, CMUS looks great, do u know also MOC and if why do you prefer CMUS? Cheers – type May 22 '11 at 13:36
  • i never used MOC before, but it looks good I will check it out. – hsinxh May 22 '11 at 13:39
  • looking at both their websites cmus looks much more current – type May 22 '11 at 13:41
  • 1
    @Harbhag could you please add a picture and a small description (makes a 1st impresssion comparison with other answers easier) – Rinzwind May 22 '11 at 13:49
  • is it possible to have cmus play in the background (with byobu and its tabs no big issue though ;) – type May 22 '11 at 13:54
  • CMUS is in the repositories. No need to download elsewhere. – Takkat May 22 '11 at 13:55
  • i used to run it in tmux, and then de-attach it from terminal, its pretty much like running in the background and you can open as many terminals as you want in the single window, here is tmux http://tmux.sourceforge.net/ – hsinxh May 22 '11 at 13:58
  • 1
    cheers, i guess screen/byobu is similar and available from the ubuntu repository if not installed by default yet --- interesting nevertheless: http://www.wikivs.com/wiki/Screen_vs_tmux / http://tmux.cvs.sourceforge.net/viewvc/tmux/tmux/FAQ – type May 22 '11 at 14:05
  • i love cmus, i use this one to, my personal favorite, recommended – dsaint May 27 '11 at 15:14
  • 1
    @type I've written a wiki page that explains how to add a little extra sugar to cmus so that it is automatically detachable/re-attachable: http://cmus.sourceforge.net/wiki/doku.php?id=detachable_cmus – jmuc Dec 12 '11 at 13:56
  • cmus is just the best! easier to setup and to learn than the other console player. and with an usefull tutorial (man cmus-tutorial) – gourgi Feb 06 '12 at 19:00
  • Also, cmus works with some vim-style keybindings. You can play music from directories, or add to a DB (best of both worlds). A neat trick is to use it in tmux, then you can ssh in from another computer (or phone). Also, it has a cli that can be used to script up whatever behavior you want. – snapfractalpop Aug 03 '16 at 13:49
  • This is almost perfect. My only wish is that I could display any arbitrary metadata in the status line. – ruslaniv Dec 19 '20 at 17:49
17

MOC

With MOC we have a powerful commandline player that is capable of browsing directories, generates playlist can can even be extended with plugins, e.g. for lastFM streams.

enter image description here

Takkat
  • 140,996
  • 54
  • 308
  • 426
  • Thanks, also looks great, do u know also CMUS and if why do you prefer MOC? Cheers – type May 22 '11 at 13:37
  • I found MOC a bit easier to handle, but that's maybe only my personal taste. – Takkat May 22 '11 at 13:48
  • MOC's default config is more 'directory' oriented behavior as opposed to other players and launch daemon at first time, you can keep playing while quitting moc interface. – Mait Dec 21 '13 at 04:57
  • The first image on this answer is down. – Calculus Knight Nov 21 '15 at 13:16
  • This is one is great too! My only wish is that I could display any arbitrary metadata in the status line – ruslaniv Dec 19 '20 at 17:50
  • Not sure if your edit an hour ago with two **MOC** links improved the answer. But deserves +1 for an edit 9 years after your original answer :) – WinEunuuchs2Unix Dec 19 '20 at 22:08
  • 1
    @WinEunuuchs2Unix: like always with such old answers it urgently needed to have linkrot removed ;) Links to the project's website, and a link to the manpage may help in figuring out how to display metadata. – Takkat Dec 20 '20 at 11:18
12

VLC has a command line interface:

cvlc -I ncurses ~/Music/

MPlayer has also a command line interface, but I am not sure if it can play audio as well.

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
Martin Ueding
  • 8,218
  • 11
  • 52
  • 83
7

Install vorbis-tools (sudo apt-get install vorbis-tools) to get ogg123:

$ ogg123 -v example.ogg 

Audio Device:   Advanced Linux Sound Architecture (ALSA) output
Author:   Bill Currie <bill@taniwha.org>/Kevin Cody, Jr. <kevinc@wuff.dhs.org>
Comments: Outputs to the Advanced Linux Sound Architecture version 0.9/1.x

Playing: example.ogg
Ogg Vorbis stream: 1 channel, 44100 Hz
Vorbis format: Version 0
Bitrate hints: upper=0 nominal=160000 lower=0 window=0
Encoded by: Xiph.Org libVorbis I 20101101 (Schaufenugget)
Encoded by: SONY IC RECORDER MP3 1.1.0
Album: ptiha
Date: 2012
Artist: Michael Laitman
Time: 00:42.17 [218:51.85] of 219:34.02  (142.0 kbps)  Output Buffer  88.9%

ogg123 reads Ogg Vorbis audio files and decodes them to the devices specified on the command line. By default, ogg123 writes to the standard sound device, but output can be sent to any number of devices. Files can be read from the file system, or URLs can be streamed via HTTP. If a directory is given, all of the files in it or its subdirectories will be played.

muru
  • 193,181
  • 53
  • 473
  • 722
daithib8
  • 3,311
  • 3
  • 24
  • 36
7

namp

namp - ncurses audio media player - is a minimalistic console-based audio player for Linux (and macOS). In addition to Winamp keybindings operation it also supports mouse control. The audio formats supported is determined by the underlying system, but generally mp3, wav, flac, etc should work fine.

namp screenshot

How to play a single sound file:

namp ~/Music/Hello.mp3

Full disclosure: I'm the author of namp. I used cmus, moc and mpd before finally settling on writing my own (very simple) audio player. It's currently not available via apt so you need to copy & paste some commands from the link above to build it from sources.

d99kris
  • 366
  • 3
  • 8
  • 1
    d99kris This app is great! Perfect amount of features before getting overly complicated and making me crave a GUI music player. – Tom Oct 10 '17 at 14:33
6

I like mplayer. It's very basic player, but sometimes I find it very useful (for example, I can specify it manually the audio driver I want it to use).

To play a file: mplayer file

As far as I know it cannot manage playlists.

Rafał Cieślak
  • 20,204
  • 7
  • 56
  • 86
  • It can play playlists if not manage them – M.T Sep 09 '16 at 07:02
  • +1 Also, if it can play all files in a directory then it can play the best playlist implementation: a directory of symlinks, which I can manage with advanced playlist management tools like `mkdir`, `mv`, `ln`, `rm`, and so on. – mtraceur Feb 20 '23 at 23:21
5

mpg123 Install mpg123

mpg123 is a fast, free and console MPEG audio player software program for UNIX and Linux operating systems. mpg123 was ported to the Windows platform using Cygwin and MinGW. It supports MPEG-1 and -2, layers 1, 2 and 3. Its most common use is to play MP3 files. It also comes as a Winamp plugin.

im1

Rinzwind
  • 293,910
  • 41
  • 570
  • 710
  • 3
    Let's not forget ogg123! – daithib8 May 25 '11 at 20:50
  • make it an answer! I get 1 to name so you can make that one :D – Rinzwind May 25 '11 at 20:51
  • who ever it was: care to explain the downvote? – Rinzwind Aug 03 '12 at 21:05
  • @Rinzwind Not me, but I just tried both mpg123 (and mpg321) and while they play mp3s fine, I'm really not interested in different players for different formats. Why should command line players be second-class-citizens? Such a GUI player would be untinkable? (ie. mpg123 can only play a limited number of formats) /necromancer – olejorgenb Jul 18 '22 at 10:42
  • @olejorgenb It's not *inherently* second class. Just tuned for a different user and use-cases that become more reasonable outside of a GUI. Consider that a GUI doesn't have `play() { "${1##*.}"123 "$1"; }`, and that some CLI users would rather run `sudo apt-get install {{whatever}}` when they finally need a new format than carry around a probably-exploitable blob of code for a player which supports tens of formats they never use. The best interface is relative to a lot of factors, and for some people a simple command per-format might actually be preferable. – mtraceur Feb 21 '23 at 00:20
5

mpd (daemon) + ncmpcpp (client/interface):

ncmpcpp

MPD is able to scan a directory and create a music library from its ID3 tags. Ncmpcpp has a library view which lets you add songs/albums/artists to the current playlist, search for tags and edit them in place.

André Paramés
  • 516
  • 3
  • 5
  • Yes, I like `mpd` too... but let's be fair and point out tha's basically the `vim` of the music players. Can support just about anything on could think of, eg. in terms of controlls and multiple in- and outputs, varying freely in in format and transport as needed. But - right, when combined with `ncmpcpp` as you show, it more like `gvim` - in a pretty good way! – Volker Siegel Jun 27 '14 at 03:59
4

For single file, check aplay, play, and paplay (for Pulseaudio only).

jarno
  • 5,317
  • 5
  • 49
  • 77
3

sudo apt install ffmpeg gives you an industry standard in playing music and videos from the command line. Two tools I use in my own GUI music player I'm starting to develop are called from the command line:

  • ffprobe gives details on songs
  • ffplay plays a song

ffprobe


ffprobe version 2.8.17-0ubuntu0.1 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x1f88060] stream 0, timescale not set
[mjpeg @ 0x1f8aa80] Changeing bps to 8
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '15 Mr. Roboto.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    creation_time   : 2012-05-16 16:41:23
    Encoding Params : vers
    iTunNORM        :  00000CD2 00000BFE 000072CF 00006BB6 0004C2DD 0004C2DD 00007FEE 00007F9B 000139A6 0001A6C4
    iTunSMPB        :  00000000 00000840 00000248 0000000000DE9978 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    iTunes_CDDB_IDs : 16++
    compilation     : 0
    disc            : 1/1
    gapless_playback: 0
    track           : 15/16
    artist          : Styx
    album           : Greatest Hits
    date            : 1983
    genre           : Rock
    title           : Mr. Roboto
    encoder         : iTunes 10.6.1.7
    composer        : Dennis DeYoung
  Duration: 00:05:30.86, start: 0.000000, bitrate: 280 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 276 kb/s (default)
    Metadata:
      creation_time   : 2012-05-16 16:41:23
    Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 316x316 [SAR 144:144 DAR 1:1], 90k tbr, 90k tbn, 90k tbc

ffplay

$ ffplay "15 Mr. Roboto.m4a"

ffplay version 2.8.17-0ubuntu0.1 Copyright (c) 2003-2020 the FFmpeg developers
  built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.12) 20160609
  configuration: --prefix=/usr --extra-version=0ubuntu0.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libavresample   2.  1.  0 /  2.  1.  0
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
  libpostproc    53.  3.100 / 53.  3.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f796c0092a0] stream 0, timescale not set
[mjpeg @ 0x7f796c00b680] Changeing bps to 8
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '15 Mr. Roboto.m4a':
  Metadata:
    major_brand     : M4A 
    minor_version   : 0
    compatible_brands: M4A mp42isom
    creation_time   : 2012-05-16 16:41:23
    Encoding Params : vers
    iTunNORM        :  00000CD2 00000BFE 000072CF 00006BB6 0004C2DD 0004C2DD 00007FEE 00007F9B 000139A6 0001A6C4
    iTunSMPB        :  00000000 00000840 00000248 0000000000DE9978 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
    iTunes_CDDB_IDs : 16++
    compilation     : 0
    disc            : 1/1
    gapless_playback: 0
    track           : 15/16
    artist          : Styx
    album           : Greatest Hits
    date            : 1983
    genre           : Rock
    title           : Mr. Roboto
    encoder         : iTunes 10.6.1.7
    composer        : Dennis DeYoung
  Duration: 00:05:30.86, start: 0.000000, bitrate: 280 kb/s
    Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 276 kb/s (default)
    Metadata:
      creation_time   : 2012-05-16 16:41:23
    Stream #0:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 316x316 [SAR 144:144 DAR 1:1], 90k tbr, 90k tbn, 90k tbc
[swscaler @ 0x7f7958033ae0] deprecated pixel format used, make sure you did set range correctly

ffplay in action

A progress counter is displayed whilst ffplay is operating and a GUI pop-up window is displayed with the song art (if X11 is not available to command line, such as console, or over ssh, then the GUI can be suppressed by adding the '-nodisp' flag:

ffplay example.gif


Incorporate ffprobe and ffplay into your own GUI

I took these tools and am starting to develop my own GUI music player:

mserve currently playing.gif

WinEunuuchs2Unix
  • 99,709
  • 34
  • 237
  • 401
2

Just write one line in terminal;) and listen to radio streams

for OGG/OPUS streams

wget -qO- http://ai-radio.org/128.opus | opusdec - - | aplay -qfdat 

be sure you have installed opus packages


for listen OGG/Vorbis radio stream just write

ogg123 http://ai-radio.org

You need to have installed vorbis packages

Enjoy

Zanna
  • 69,223
  • 56
  • 216
  • 327
artem
  • 21
  • 1
0

mpg123 (http://www.mpg123.org/)

it's in the universe repositories, supports playlists and streaming from web-sources. When startet with -C you can also skip tracks in playlist etc. edit: not sure about ogg support.


music123

A command-line shell for programs like mpg123 and ogg123, music123 plays a variety of sound files using a mpg123/ogg123-like interface. With all the Recommends installed, music123 plays wav, mp3 and ogg files. By simply changing the config file, music123 can play any sound file you have a player for.

(If you install a recent version of vorbis-tools, music123 will handle Ogg Flac and Ogg Speex files too.)

marto
  • 1,373
  • 2
  • 15
  • 25
0

cmus

Plugins Input: Ogg Vorbis, MP3, FLAC, Musepack, WavPack, WAV, AAC, MP4, and everything supported by ffmpeg (WMA, APE, MKA, TTA, SHN, ...) and libmodplug Output: PulseAudio, ALSA, OSS, RoarAudio, libao, aRts, Sun, and WaveOut (Windows)

http://cmus.sourceforge.net/#features

0

I've used mp3blaster in the past. It supports Playlists, Groups, Repeat, Search. Not many special features.

belacqua
  • 22,880
  • 23
  • 88
  • 108
RobinJ
  • 8,800
  • 8
  • 46
  • 69
0

Following on from the excellent shell pipeline answer given by @artem here's an mp3 version that I've just worked out:

URL=http://direct.fipradio.fr/live/fip-midfi.mp3
wget -qO- $URL | lame --quiet --decode --mp3input - - | pacat

(if you're not using pulseaudio, just swap the pacat for aplay)

jaimet
  • 166
  • 2