-
Notifications
You must be signed in to change notification settings - Fork 0
music streaming setup
This looks more complicated and overwhelming as it is...
Sidenote: you may be more happy using Mopidy if you only want to stream locally from a media server
+--------------+ +---------+ +------------+ <----------+ +------------+ ++
| | | | |------------| | Icecast | +--+ +-->
| MPD client | +------> | MPD | +------> || || <----------+ | Client(s) | +-+ |
| | | | || || | | | |
+--------------+ +---------+ || Icecast2 || | (HiFi | +------> | Speaker +--->
|| server || . | Receiver, | | |
+-----------------------------------+ || || . | Laptop, | +-+ |
|Any other Icecast2 capable | +------> || || . | ...) | +--+ +-->
|application (i.e. VLC, Mixxx, ...) | +------> |------------| | | ++
+-----------------------------------+ +------------+ <----------+ +------------+
- MPD (Music Player Deamon) - I needed an web-based player to control the audio stream
- Using the Icecast2 allows us to feed the stream (or many streams) by any capable player (examples can be found in the flowchart above)
- Any listener can stream from the Icecast2 server (like a HiFi receiver, VLC player, web-based player, ...)
- Install the
icecast2
package. Follow the instructions of the installer for configuration. - Edit
/etc/icecast2/icecast.xml
(You want<location>
,<admin>
, increase<sources>
)- The default mount point is
stream
. Only enable it in the settings if advanced options are needed
- The default mount point is
- Start and enable the icecast server:
systemctl start icecast
,systemctl enable icecast
orsudo /etc/init.d/icecast2 start
etc.
-> Continue with the Streaming with MPD section https://wiki.archlinux.org/index.php/Icecast.
Icecast webpage: http://<hostname>:8000/
- Sidenotes mainly related to the config file:
/etc/icecast.xml
or/etc/icecast2/icecast.xml
- Source is your "player" (MPD, Mixxx, ...)
- Relay nodes are relevant for more complex (yes, it can get even more complex ;) ) scenarios
- The admin part should be self-explanatory (if not: navigate to your (local) icecast server website)
At this point you could already start streaming (from Mixxx for instance):
- Host = IP/DNS or your icecast server
- Mount =
stream
- Login =
source
- Password = your password defined during installation
Basically I followed this: https://wiki.archlinux.org/index.php/Music_Player_Daemon
- Do the normal Setup
- I used global configuration since I think it's better for a server
- My music database lies under
/mnt/database
=> no permission errors (you can cheat withsudo mount --bind 'sourceDir' 'mountDir'
if you have it locally and want to use it this way)- To exclude files from the database, create a file called .mpdignore in the parent music directory. Each line of that file may contain a list of shell wildcards. Matching files in the current directory and all subdirectories are excluded.
- Regarding audio configuration see the
mpd.conf
(and its comments) below
# See: /usr/share/doc/mpd/mpdconf.example
pid_file "/run/mpd/mpd.pid"
db_file "/var/lib/mpd/mpd.db"
state_file "/var/lib/mpd/mpdstate"
playlist_directory "/var/lib/mpd/playlists"
music_directory "/mnt/testmout"
restore_paused "no"
auto_update "yes"
metadata_to_use "artist,album,title,track,name,genre,date,composer,performer,disc"
replaygain "auto"
# volume_normalization "yes"
filesystem_charset "UTF-8"
# Needed in order to let icecast work (otherwise no audio)
audio_output {
type "pulse"
name "MPD PulseAudio Out"
# Needed, otherwise no audio (worth trying without first)
mixer_type "software"
}
audio_output {
type "shout"
encoding "ogg"
name "MrSpell Teststream"
# host "192.168.1.224"
host "localhost"
port "8000"
mount "/stream"
# icecast source pw
password "playerpw"
user "source"
quality "9.0"
# samplerate:bits:channels
format "48000:32:2"
}
# Need this that mpd still works if icecast is not running
audio_output {
type "null"
name "fake out"
}
- Then,
start
andenable
the mpd service (systemctl start mpd.service
, ...) - You might get the WARNING:
Mar 05 02:51:32 vAntergosXFCE mpd[24818]: exception: bind to '0.0.0.0:6600' failed (continuing anyway, because binding to '[::]:6600' succeeded): Failed to bind socket: Address already in use
- You should be fine if
Mar 05 02:51:32 vAntergosXFCE systemd[1]: Started Music Player Daemon.
occurs afterwards (this is because of the IPv6 preference over IPv4 in mpd)
- You should be fine if
Almost done!
yaourt -S ympd
- Create a
ympd.service
config - Then,
start
andenable
the ympd service (systemctl start ympd.service
, ...) - You might not see any songs in your database (update via
mpc update
or via the settings menu on your (local) ympd website)
ympd.service:
[Unit]
Description=ympd (music streaming web front-end)
After=mpd.service network.target
[Service]
Type=simple
ExecStart=/usr/bin/ympd
[Install]
WantedBy=multi-user.target
Comand-line tool to control the MPD client
Update music database
mpc update
Get some playing information
$ mpc repeat on
volume: 80% repeat: on random: off single: off consume: off
$ mpc play
Jono Bacon - Free Software Song 2
[playing] #1/1 0:00/3:18 (0%)
volume: 80% repeat: on random: off single: off consume: off
I wanted to use Ogg since the ratio qulity/bitrate is slightly better; therefore an overview over the quality levels
Switch VBR target(kbit/s) VBR range (kbit/s)
-q 0 ~64 ~64 – ~80
-q 1 ~80 ~80 – ~96
-q 2 ~96 ~96 – ~112
-q 3 ~112 ~112 – ~128
-q 4 ~128 ~128 – ~160
-q 5 ~160 ~160 – ~192
-q 6 ~192 ~192 – ~224
-q 7 ~224 ~224 – ~256
-q 8 ~256 ~256 – ~320
-q 9 ~320 ~320 – ~500
-q 10 ~500 ~500 – ~1000
Switch Preset Target Typical
bitrate [Kbps] bitrate [Kbps]
-b 320 --preset insane 320 320
-V 0 --preset extreme ~240 220–260
-V 1 ~220 190–250
-V 2 --preset standard ~190 170–210
-V 3 ~170 150–195
-V 4 --preset medium ~160 140–185
-V 5 ~130 120–150
-V 6 ~120 100–130
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License *.
Code (snippets) are licensed under a MIT License *.
* Unless stated otherwise