Mplayer: Play Audio CD Using Linux Command Line

How do I play a music cd using MPlayer command line in Linux?

MPlayer is a free and open source media player which can play physical media such as CDs, DVDs, Video CDs and various music formats using command line options. Mplayer has Compact Disc Digital Audio system (CDDA) support to play entire music / audio cd or specific track.


The syntax is as follows (open the terminal type the command):

mplayer -cdrom-device /dev/cdrom cdda://
mplayer -cdrom-device /dev/sr0 cdda://

Sample outputs:

Fig.01: mplayer in Action

Setting CDROM Name

The -cdrom-device option specify the CD-ROM device (default: /dev/cdrom). In this example, /dev/sr0 is my actual DVD / cd player under Linux.

Getting Around Buffering Problem

The audio playback may be interrupted ever few hundred milliseconds. You need to cache or buffer in advance using -cache option as follows:

mplayer -cdrom-device /dev/sr0 cdda:// -cache 5000

How Do I Play Specific Tracks?

To play specific tracks, you need to specify the number. In this example play track # 5:

mplayer -cdrom-device cdda://5 -cache 5000

Sample outputs:

Playing cdda://5.
Found audio CD with 7 tracks.
Cache fill:  0.00% (0 bytes)   
Track 5

Track 5
rawaudio file format detected.
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
AO: [pulse] 44100Hz 2ch s16le (2 bytes per sample)

You can play tracks 6 to 13 as follows:

mplayer -cdrom-device cdda://6-13 -cache 5000

Configuring Mplayer

You may want to add all options and parameter in your $HOME/.mplayer/config file, so you don’t have to specify every time. Edit ~/.mplayer/config, enter:
$ vi ~/.mplayer/config
Edit / modify as follows:

# default cdrom
# cache setting
# set audio driver

Save and close the file. Now, you can simply type the following command:
$ mplayer cdda://
$ mplayer cdda://5

Useful Keyboard Shortcuts

Quoting from the mplayer man page:

               :  Seek backward/forward 10 seconds.
              up and down : Seek forward/backward 1 minute.
              pgup and pgdown : Seek forward/backward 10 minutes.
              [ and ] : Decrease/increase current playback speed by 10%.
              { and } : Halve/double current playback speed.
              backspace : Reset playback speed to normal.
               : Go backward/forward in the playlist (not for audio cds).
              ENTER : Go forward in the playlist, even over the end.
              HOME and END : next/previous playtree entry in the parent list
              p / SPACE : Pause (pressing again unpauses).
              q / ESC : Stop playing and quit.
              + and - : Adjust audio delay by +/- 0.1 seconds.
              / and * : Decrease/increase volume.
              9 and 0 : Decrease/increase volume.
              ( and ) : Adjust audio balance in favor of left/right channel.
              m :  Mute sound.
              o : Toggle OSD states: none / seek / seek + timer / seek + timer + total time.

Further readings:

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 4 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
4 comments… add one
  • Richard Sep 30, 2010 @ 9:29

    Or you can just use Herrie as an excellent command line audio player –
    I use it an awful lot and it has a very small memory and processor footprint.

  • carlos Dec 24, 2010 @ 11:44

    Thank you very much for this useful post and for you blog.

  • Andriy Mar 21, 2011 @ 19:01

    Setting ‘cache=5000’ for all files played (i.e, setting it in the configfile) have side effects. In my case it was some mp4-coded videos choppy playback.

  • Robinson Grullon Nov 24, 2012 @ 22:43

    Thank you very much endee, this was a very useful howto. I hope you keep on doing this kind of contribution to the new users. Congratulations!!! God bless you. Sincerely.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum