Media center setup
Go to file
2023-03-15 11:18:37 +01:00
etc First commit. 2023-03-15 11:18:37 +01:00
utilities First commit. 2023-03-15 11:18:37 +01:00
README.md First commit. 2023-03-15 11:18:37 +01:00

media-center-setup

This is my setup for my media center. Its main purpose is for me to be able to replicate it, in case of need. However, with a few modifications, it can be a great way for you to have a Raspberry Pi with the following features:

  • an mpd server to stream local music, with an equalizer and snapcast support to stream.
  • an Airplay capable machine (for Apple Music for example).
  • a place to stream videos through Samba and NFS.

Prerequisites

  • An SD card, with the latest 64-bit Raspberry Pi OS installed on it. Use Raspberry Pi imager for that purpose.
  • A Raspberry Pi, where the firmware has been updated with the possibility of USB booting.

First configuration

  • Insert the SD card in the Pi, start up, and SSH to it.
  • Be sure to be in the wanted distribution target. For instance, I regularly need to be in testing, for mpd to be up to date. This can be done my modifying /etc/apt/sources.list. I usually type in the explicit name of testing (currently bookworm) to be sure where I'm at.
  • Run sudo apt update && sudo apt dist-upgrade && sudo apt upgrade to update the system to the last version we need.
  • Run sudo apt install mpd mpc libasound2-plugin-equal shairport-sync snapserver samba nfs-kernel-server vim to install the needed packages.

Copying the SD card data to the USB media

Please note that this step can be done after the other configurations are performed, as most of the things will be copied.

  • Transfer the utilities folder to your Pi.
  • Inside, there is a folder called usb-boot. It comes from RonR, a user from the Raspberry Pi forums. You can also download it here. The version included in this repository is from Feb 28, 2022.
  • Run usb-boot.sh.
  • You can now remove your SD card and boot the system from the USB media device.

Configuring the audio

  • I use a HifiBerry DAC. For that purpose, I need to do the following:
    • update /boot/config.txt
    • remove dtparam=audio=on
    • add dtoverlay=hifiberry-dacplusadc (find what you need on the documentation)
    • while you're on this file, you can also disable things you probably don't need like bluetooth (dtoverlay=disable-bt) or WiFi (dtoverlay=disable-wifi).
  • Copy the /etc/asound.conf file.
  • You can use the equalizer.sh script to configure the equalizer. A value I like is 74-66-64-66-72-72-66-64-66-74.

Troubleshooting audio

If you're having trouble with the Raspberry Pi audio, try one of the following things:

  • sudo raspi-config => 1 System Options => S2 Audio.
  • list your devices with aplay -l.
  • try speaker-test -c 2, it should output sound.
  • you can also try speaker-test -D hw:<card number>,<device number>.

Configuring mpd

My music is copied with rsync through my NAS. For that purpose I use a set of scripts, that you would have to modify to suit your needs.

  • Fist, we create a folder where we'll mount to NAS: mkdir /media/mantis-music.
  • Then a folder where to copy the music: mkdir /home/pi/music.
  • Use to script to copy locally the music: utilities/update-music.sh.
  • Copy the mpd configuration file in /etc/mpd.conf.
  • Run mpc update, then mpc ls to try to play something with mpc play.
  • Test right away, it should output sound if you've rightly configured your audio.

Configuring the sharing

Samba

I use Samba to be able to organize my videos through my Windows machine.

  • Edit /etc/samba/smb.conf and add the following:
    [VideoPi]
        comment = Videos on Pi 
        path = /home/pi/video
        read only = no
        browsable = yes
    
  • Then set up a password for the user pi: sudo smbpasswd -a pi
  • You should be able to connect to it.

NFS

NFS is used to communicate with my Linux machine reading videos through Kodi.

  • Edit /etc/exports and add the following line to make it visible to the home network: /home/pi/video 192.168.1.0/24(rw,all_squash,insecure).
  • You should be able to connect to it.

Utilities

  • equalizer.sh allows you to modify the equalizer values of Alsamixer.
  • update-music.sh calls the following two scripts to update your music:
    • update-music/mount-nfs.sh mounts the NAS volume.
    • update-music/rsync-sync.sh performs an rsync to copy the music.
  • temperature.sh displays the current Raspberry Pi temperature.
  • add-cover.sh extracts covers from the music files to make a cover.jpg file. Useful for old mpd that is not able to read directly into the file.
  • video-tools/video-infos.sh extract infos from the videos to verify if they're readable as needed.
  • usb-boot a set of script documented here.