media-center-setup/README.md

104 lines
6.1 KiB
Markdown
Raw Permalink Normal View History

2023-03-15 10:18:37 +00: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).
2024-04-16 17:27:39 +00:00
- a place to organize and stream videos through Samba and NFS.
2023-03-15 10:18:37 +00:00
## Prerequisites
* An SD card, with the latest 64-bit Raspberry Pi OS installed on it. Use [Raspberry Pi imager](https://www.raspberrypi.com/software/) 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.
2024-04-16 17:27:39 +00:00
* 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 _trixie_) to be sure where I'm at.
2023-03-15 10:18:37 +00:00
* 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
2024-04-16 17:27:39 +00:00
Please note that this step can be done after the other configurations are performed, as most of the things will be copied from the SD card to the USB media device.
2023-03-15 10:18:37 +00:00
* Transfer the utilities folder to your Pi.
2024-04-16 17:27:39 +00:00
* 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](https://forums.raspberrypi.com/viewtopic.php?t=196778). The version included in this repository is from Feb 11, 2024.
2023-03-15 10:18:37 +00:00
* 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](https://www.hifiberry.com/docs/software/configuring-linux-3-18-x/))
* 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`.
2024-04-16 17:27:39 +00:00
* Use to script to copy locally the music: `utilities/1-update-music.sh`.
* Edit `/etc/mpd.conf` and add the content from this repository.
2023-03-15 10:18:37 +00:00
* 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.
2024-04-16 17:27:39 +00:00
### Going further
* You can extract the cover of audio files and uploading them to your NAS by running `utilities/2-cover-upload.sh`.
* You can remove unwated files (such as `.DS_Store` and `Thumbs.db`) and uploading these changes to your NAS by running `utilities/3-remove-unwanted-files.sh`.
## Configuring sharing
2023-03-15 10:18:37 +00:00
### Samba
I use Samba to be able to organize my videos through my Windows machine.
2024-04-16 17:27:39 +00:00
* Edit `/etc/samba/smb.conf` and add the content from this repository.
2023-03-15 10:18:37 +00:00
* 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.
2024-04-16 17:27:39 +00:00
* Edit `/etc/exports` and add the content from this repository.
2023-03-15 10:18:37 +00:00
* You should be able to connect to it.
2024-04-16 17:27:39 +00:00
## video-info.sh
### Use case
I bought a machine named Vero 4K+, running OSMC, to read my video library on my TV. It works fine on a number of files, but was struggling on some others, when no hardware decoder was available. I [found this thread](https://discourse.osmc.tv/t/ff-h264-dropping-and-skipping-frames/37459) that gave a first hint. I then decided to made a quick list of all the format of my files, to be able to test them.
### Usage
`video-info.sh` generates a CSV file with the format, the format profile, and the codec ID. It can be opened with any spreadsheet software. If it is interrupted, an option to resume the operation is available, so that it is possible to launch it multiple time on huge video libraries.
It generates a file named `videoinfo-date_hour.csv` in the folder where the videos are located.
By default, only the following file extensions are taken into account: `mkv`, `mp4`, and `avi`. You can easily add more by modifying the script. You can know which file extensions you have in your library by typing the following command (more [on this thread](https://stackoverflow.com/questions/1842254/how-can-i-find-all-of-the-distinct-file-extensions-in-a-folder-hierarchy)):
`find . -type f | sed -e 's/.*\.//' | sed -e 's/.*\///' | sort | uniq -c | sort -rn`
2023-03-15 10:18:37 +00:00
## Utilities
2024-04-16 17:27:39 +00:00
* `1-update-music.sh` mounts the NAS and downloads music to the Raspberry Pi.
* `2-cover-upload.sh` extracts a cover.jpg file from songs and uploads it to the NAS.
* `3-remove-unwanted-files.sh` removes unwanted files such as `.DS_Store` and pushes those modifications to the NAS.
2023-03-15 10:18:37 +00:00
* `equalizer.sh` allows you to modify the equalizer values of Alsamixer.
* `temperature.sh` displays the current Raspberry Pi temperature.
2024-04-16 17:27:39 +00:00
* `video-infos.sh` extract infos from the videos to verify if they're readable as needed.
* `usb-boot` a set of script [documented here](https://forums.raspberrypi.com/viewtopic.php?t=196778).