ubuntu系统使用命令行播放MP3歌曲

无论是在linux系统还是在windows系统,我们一般都是习惯于使用界面来播放MP3音乐,下面介绍一种使用命令行的形式来播放音乐,这个软件的名字叫SOX。我们需要先安装一下软件,然后通过命令行来使用这个软件播放音乐,这个软件支持很多格式的音频文件,如 WAV,MP3,MPG,OGG,FLAC 等等

1、安装软件,在安装的时候询问你是否继续的时候输入 Y 来确认继续安装。
sudo apt-get install sox

czd@ubuntu:~$ sudo apt-get install sox
[sudo] password for czd: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libgsm1 libopencore-amrnb0 libopencore-amrwb0 libsox-fmt-alsa libsox-fmt-base libsox1b
Suggested packages:
  libsox-fmt-all
The following NEW packages will be installed:
  libgsm1 libopencore-amrnb0 libopencore-amrwb0 libsox-fmt-alsa libsox-fmt-base libsox1b sox
0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
Need to get 578 kB of archives.
After this operation, 1,742 kB of additional disk space will be used.
Do you want to continue [Y/n]? y

2、完成安装以后,可以通过下面的命令来让 SOX 可以播放它所支持的音频格式文件
sudo apt-get install sox libsox-fmt-all

czd@ubuntu:~$ sudo apt-get install sox libsox-fmt-all
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sox is already the newest version.
The following extra packages will be installed:
  libao-common libao4 libavcodec53 libavformat53 libavutil51 libid3tag0 libmad0 libmp3lame0 libschroedinger-1.0-0 libsox-fmt-ao libsox-fmt-ffmpeg libsox-fmt-mp3 libsox-fmt-oss libsox-fmt-pulse libva1
  libvpx1
Suggested packages:
  libesd0 libesd-alsa0 libroar1 libsndio0 roaraudio-server
The following NEW packages will be installed:
  libao-common libao4 libavcodec53 libavformat53 libavutil51 libid3tag0 libmad0 libmp3lame0 libschroedinger-1.0-0 libsox-fmt-all libsox-fmt-ao libsox-fmt-ffmpeg libsox-fmt-mp3 libsox-fmt-oss
  libsox-fmt-pulse libva1 libvpx1
0 upgraded, 17 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,454 kB of archives.
After this operation, 11.5 MB of additional disk space will be used.
Do you want to continue [Y/n]? y

3、比如要播放系统中的音频文件,我们可以采用这个命令:
play *mp3

czd@ubuntu:~$ play /home/share/zuishuxidemoshengren.mp3 

/home/share/zuishuxidemoshengren.mp3:

 File Size: 4.19M     Bit Rate: 128k
  Encoding: MPEG audio    Info: 2004
  Channels: 2 @ 16-bit   Track: 2
Samplerate: 44100Hz      Album: Ê×Ñ¡ÏôÑÇÐù¨BÃÀÀöµÄ²åÇú
Replaygain: off         Artist: ÏôÑÇÐù
  Duration: 00:04:22.07  Title: ×îÊìϤµÄÄ°ÉúÈË

In:1.35% 00:00:03.53 [00:04:18.54] Out:156k  [!=====|=====!] Hd:0.0 Clip:51

你可能感兴趣的:(Linux开发,sox,linux播放MP3)