Music Player Daemon on OpenWrt

OpenWrt works on Raspberry Pi very well.
Pi comes with a 3.5mm audio jack.
I can turn it into a Music Player.

Build Packages

# docker pull vimagick/openwrt:bcm2710
# docker run -d --name openwrt_bcm2710 vimagick/openwrt:bcm2710 sleep infinity
# docker exec -it openwrt_bcm2710 bash

$ cd sdk
$ chmod 777 bin

$ vi Config-build.in
  config BUILD_NLS
          bool
-         default n
+         default y

$ ./scripts/feeds update -a
$ ./scripts/feeds install mpd mpc

$ vi package/feeds/packages/mpd/Makefile
- PKG_VERSION:=0.19.17
+ PKG_VERSION:=0.19.19

- PKG_MD5SUM:=47e13f3f160bf94e7a897c5a48990f3d
+ PKG_MD5SUM:=6e4fca9a9c26dad08b61bac9a91802db

-       +libmms +libogg +libsndfile +libvorbis +libupnp
+       +libmms +libogg +libsndfile +libvorbis +libupnp +libshout +lame-lib

+       --enable-lame-encoder \
-       --disable-shout \
+       --enable-shout \
-       --disable-vorbis-encoder \
+       --enable-vorbis-encoder \


$ make defconfig
$ make menuconfig
$ IGNORE_ERRORS=1 make

$ find bin -name 'mp[dc]*.ipk'
bin/packages/arm_cortex-a53_neon-vfpv4/packages/mpc_0.27-1_arm_cortex-a53_neon-vfpv4.ipk  
bin/packages/arm_cortex-a53_neon-vfpv4/packages/mpd-mini_0.19.18-1_arm_cortex-a53_neon-vfpv4.ipk  
bin/packages/arm_cortex-a53_neon-vfpv4/packages/mpd-avahi-service_0.19.18-1_arm_cortex-a53_neon-vfpv4.ipk  
bin/packages/arm_cortex-a53_neon-vfpv4/packages/mpd-full_0.19.18-1_arm_cortex-a53_neon-vfpv4.ipk

$ find bin -name 'boost*.ipk'

WARNING: vorbis-encoder will cause Segmentation fault

Install Packages

  • mpd: Muisc Player Daemon
  • mpc: Music Player Client
  • icecast: Media Streaming Service
$ opkg update
$ opkg install boost*.ipk mpd-full*.ipk libintl-full icecast
$ mpd --version

Mount USB

$ opkg install block-mount lsblk

$ lsblk -f
NAME        FSTYPE LABEL UUID                                 MOUNTPOINT  
sda  
`-sda1      ext4         4c1dd9cf-a5a8-4917-a931-1390fca6cc26 /mnt/usb
mmcblk0  
|-mmcblk0p1 vfat         E0EB-2434                            /boot
`-mmcblk0p2 ext4         57f8f4bc-abf4-655f-bf67-946fc0f9f25b /

$ vi /etc/config/fstab
config 'mount'  
        option  target  '/mnt/usb'
        option  uuid    '4c1dd9cf-a5a8-4917-a931-1390fca6cc26'
        option  enabled '1'

$ block mount
$ mkdir -p /mnt/usb/mpd/music \
           /mnt/usb/mpd/playlists
$ ls /mnt/usb/mpd/
database   mpd.log    music/      playlists/  state  

CLI Client

  • Put mp3 files into /mnt/usb/mpd/music
  • Put m3u files into /mnt/usb/mpd/playlists
$ mpc help
$ mpc update
$ mpc ls | mpc add
$ mpc repeat on
$ mpc random on
$ mpc

Conifg MPD

# /etc/mpd.conf

music_directory    "/mnt/usb/mpd/music"  
playlist_directory "/mnt/usb/mpd/playlists"  
db_file            "/mnt/usb/mpd/database"  
log_file           "/mnt/usb/mpd/mpd.log"  
pid_file           "/var/run/mpd.pid"  
state_file         "/mnt/usb/mpd/state"  
sticker_file       "/mnt/usb/mpd/sticker.sql"

input {  
        plugin "curl"
}

input {  
        plugin "alsa"
}

audio_output {  
        type            "alsa"
        name            "Default Audio Device"
        mixer_type      "software"
}

audio_output {  
        type            "httpd"
        name            "My HTTP Stream"
        encoder         "lame"
        port            "8800"
        bitrate         "128"
        format          "44100:16:1"
        always_on       "yes"
        tags            "yes"
}

audio_output {  
        type            "shout"
        encoding        "lame"
        name            "My Shout Stream"
        host            "127.0.0.1"
        port            "8000"
        mount           "/mpd.mp3"
        password        "hackme"
        bitrate         "128"
        format          "44100:16:1"
}

Input plugin alsa can read usb microphone (alsa://plughw:1,0) for live streaming.

Debug MPD

$ /etc/init.d/mpd stop
$ mpd -v --stdout --no-daemon
$ /etc/init.d/mpd start

Client Setup

Read More