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.?
0

15 Answers 15

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

13
  • Thanks, CMUS looks great, do u know also MOC and if why do you prefer CMUS? Cheers
    – type
    May 22, 2011 at 13:36
  • i never used MOC before, but it looks good I will check it out.
    – hsinxh
    May 22, 2011 at 13:39
  • 1
    @Harbhag could you please add a picture and a small description (makes a 1st impresssion comparison with other answers easier)
    – Rinzwind
    May 22, 2011 at 13:49
  • 1
    cheers, i guess screen/byobu is similar and available from the ubuntu repository if not installed by default yet --- interesting nevertheless: wikivs.com/wiki/Screen_vs_tmux / tmux.cvs.sourceforge.net/viewvc/tmux/tmux/FAQ
    – type
    May 22, 2011 at 14:05
  • 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: cmus.sourceforge.net/wiki/doku.php?id=detachable_cmus
    – jmuc
    Dec 12, 2011 at 13:56
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

7
  • Thanks, also looks great, do u know also CMUS and if why do you prefer MOC? Cheers
    – type
    May 22, 2011 at 13:37
  • I found MOC a bit easier to handle, but that's maybe only my personal taste.
    – Takkat
    May 22, 2011 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, 2013 at 4:57
  • The first image on this answer is down. Nov 21, 2015 at 13:16
  • 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, 2020 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.

2
  • 3
    VLS has a great ncurses interface cvlc -I ncurses musique/*
    – meduz
    Oct 15, 2013 at 8:22
  • It is possible to run it in dark mode? Jan 25, 2017 at 4:33
8

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.

1
  • 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, 2017 at 14:33
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 <[email protected]>/Kevin Cody, Jr. <[email protected]>
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.

2
  • The image on this answer is down. Nov 21, 2015 at 13:17
  • Only plays ogg files..
    – olejorgenb
    Jul 18, 2022 at 10:46
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.

2
  • It can play playlists if not manage them
    – M.T
    Sep 9, 2016 at 7: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, 2023 at 23:21
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.

1
  • 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! Jun 27, 2014 at 3:59
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

5
  • 3
    Let's not forget ogg123!
    – daithib8
    May 25, 2011 at 20:50
  • make it an answer! I get 1 to name so you can make that one :D
    – Rinzwind
    May 25, 2011 at 20:51
  • who ever it was: care to explain the downvote?
    – Rinzwind
    Aug 3, 2012 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, 2022 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, 2023 at 0:20
4

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

3
  • 1
    Should point out this answer is better from point of view paplay is installed by default. Oct 25, 2018 at 2:12
  • 1
    Note that play is part of the sox set of tools. On Debian, install the sox package.
    – dat
    Feb 16, 2021 at 19:13
  • aplay: No keyboard controls.. (except toggling play with -i -_-)
    – olejorgenb
    Jul 18, 2022 at 10:50
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

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

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.)

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.

2
  • any features worth mentioning?
    – type
    Jul 4, 2011 at 21:44
  • 1
    Playlists, Groups, Repeat, Search. Not many special features.
    – RobinJ
    Jul 4, 2011 at 21:48
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)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .