<SOLVED> Streaming with MPD and Icecast2

Kernels & Hardware, configuring network, installing services

Re: Streaming with MPD and Icecast2

Postby Dennis99 » 2020-03-28 21:44

Whether it makes a difference or not I'm not sure but mine is:
Code: Select all
music_directory         "/home/radio/Library"
playlist_directory              "/home/radio/Library/playlists"
 user            "<user>"           <-------- Mine is the equivalent of here

Audio_output {
#       type            "shout"
        encoding        "mp3"
        type            "httpd"
        name            "My Radio"
        description     "My Radio"
        host            "localhost"
        mount           "/mpd.mp3"
        port            "8000"
        tags            "yes"
#       quality         "5.0"
        bitrate         "192"

Again try:
Code: Select all
sudo systemctl stop mpd.service
to stop mpd.

Then
Code: Select all
$ pidof mpd
to see if it is still running, if it is kill it. I've never figured out why systemctl doesn't always stop it!
Also for later on you don't need a mount for httpd, change encoding to encoder and comment out tags for now.
You should be able to test it out locally by putting 127.0.0.1:8000 in a browser.
Off to bed now, we are putting the clocks on one hour for British Summertime, so lose an hour's sleep. :(

Code: Select all
Yes - Gates of Delirium
[playing] #2685/3289   0:33/21:45 (2%)
volume: n/a   repeat: on    random: on    single: off   consume: off
Dennis99
 
Posts: 19
Joined: 2012-07-24 15:02

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-03-28 23:01

Jesus. I've been waiting for a response and didn't see the thread had moved on to page 2. Derp.

Anyway, systemctl did successfully stop the service. I have commented out tags and the mount. I don't know if httpd is the type I should be using for icecast or what I'm doing. Maybe shout would be better? That's one of the things that so confused me about all the tutorials. They all said to use different types and were very inconsistent. It looks like I have user defined in 3 different places, actually. It's always the same user though, so that shouldn't mess things up, right? And to test with 127.0.0.1:8000 I probably need to start mpd again, yeah?

If run as root:
Code: Select all
# systemctl start mpd.service
Job for mpd.service failed because the control process exited with error code.
See "systemctl status mpd.service" and "journalctl -xe" for details.
Honestly, I was surprised it was running in the first place.
Code: Select all
# systemctl status mpd.service
● mpd.service - Music Player Daemon
   Loaded: loaded (/lib/systemd/system/mpd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-03-28 16:54:57 PDT; 4min 53s ago
     Docs: man:mpd(1)
           man:mpd.conf(5)
           file:///usr/share/doc/mpd/user-manual.html
  Process: 717 ExecStart=/usr/bin/mpd --no-daemon $MPDCONF (code=exited, status=1/FAILURE)
 Main PID: 717 (code=exited, status=1/FAILURE)

Mar 28 16:54:56 <username> systemd[1]: Starting Music Player Daemon...
Mar 28 16:54:56 <username> mpd[717]: exception: Error in /etc/mpd.conf line 71
Mar 28 16:54:56 <username> mpd[717]: exception: nested: config parameter "user" is first defined on line 23 and redefined on
Mar 28 16:54:57 <username> systemd[1]: mpd.service: Main process exited, code=exited, status=1/FAILURE
Mar 28 16:54:57 <username> systemd[1]: mpd.service: Failed with result 'exit-code'.
Mar 28 16:54:57 <username> systemd[1]: Failed to start Music Player Daemon.
# journalctl -xe
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit session-7.scope has finished successfully.
--
-- The job identifier is 566.
Mar 28 16:59:38 <username> su[734]: (to root) <username> on pts/1
Mar 28 16:59:38 <username> su[734]: pam_unix(su-l:session): session opened for user root by <username>(uid=1000)
Mar 28 16:59:51 <username> dhclient[382]: DHCPDISCOVER on enp2s0 to 255.255.255.255 port 67 interval 5
Mar 28 16:59:56 <username> dhclient[382]: DHCPDISCOVER on enp2s0 to 255.255.255.255 port 67 interval 10
Mar 28 17:00:06 <username> dhclient[382]: DHCPDISCOVER on enp2s0 to 255.255.255.255 port 67 interval 19
Mar 28 17:00:25 <username> dhclient[382]: DHCPDISCOVER on enp2s0 to 255.255.255.255 port 67 interval 9
Mar 28 17:00:34 <username> dhclient[382]: DHCPDISCOVER on enp2s0 to 255.255.255.255 port 67 interval 7
Mar 28 17:00:41 <username> dhclient[382]: DHCPDISCOVER on enp2s0 to 255.255.255.255 port 67 interval 11
Mar 28 17:00:52 <username> dhclient[382]: No DHCPOFFERS received.
Mar 28 17:00:52 <username> dhclient[382]: No working leases in persistent database - sleeping.
Mar 28 17:00:52 <username> root[745]: /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd returned non-zero exit status 1
Mar 28 17:01:16 <username> systemd[1]: Starting Music Player Daemon...
-- Subject: A start job for unit mpd.service has begun execution
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit mpd.service has begun execution.
--
-- The job identifier is 628.
Mar 28 17:01:17 <username> mpd[748]: exception: Error in /etc/mpd.conf line 71
Mar 28 17:01:17 <username> mpd[748]: exception: nested: config parameter "user" is first defined on line 23 and redefined on
Mar 28 17:01:17 <username> systemd[1]: mpd.service: Main process exited, code=exited, status=1/FAILURE
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- An ExecStart= process belonging to unit mpd.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 1.
Mar 28 17:01:17 <username> systemd[1]: mpd.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The unit mpd.service has entered the 'failed' state with result 'exit-code'.
Mar 28 17:01:17 <username> systemd[1]: Failed to start Music Player Daemon.
-- Subject: A start job for unit mpd.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- A start job for unit mpd.service has finished with a failure.
--
-- The job identifier is 628 and the job result is failed.

If run as user:
Code: Select all
$ systemctl start mpd.service
Failed to start mpd.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status mpd.service' for details.
$ systemctl start mpd.service
Failed to start mpd.service: The name org.freedesktop.PolicyKit1 was not provided by any .service files
See system logs and 'systemctl status mpd.service' for details.
radio@radio:~$ systemctl status mpd.service
● mpd.service - Music Player Daemon
   Loaded: loaded (/lib/systemd/system/mpd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2020-03-28 18:33:50 PDT; 51min ago
     Docs: man:mpd(1)
           man:mpd.conf(5)
           file:///usr/share/doc/mpd/user-manual.html
  Process: 914 ExecStart=/usr/bin/mpd --no-daemon $MPDCONF (code=exited, status=1/FAILURE)
 Main PID: 914 (code=exited, status=1/FAILURE)
$ journalctl -xe
Hint: You are currently not seeing messages from other users and the system.
      Users in the 'systemd-journal' group can see all messages. Pass -q to
      turn off this notice.
No journal files were opened due to insufficient permissions.

The username is the same as the host name, FYI.

I would also probably have to use the LAN IP of my mpd server, since it's running headless with console only and doesn't have a browser. All this work I'm doing to it is via SSH in the terminal.

Have a good night, dude. We can pick this up again whenever you're ready. Daylight savings time is stupid and should just be abolished.

Also, yes, that is some consolation. All the tutorials about this are either incomplete or old as hell and they're all so different it's hard to figure out what I'm doing.
Head_on_a_Stick wrote:Have you just Rick-rolled this thread? :mrgreen:

As a punishment open a terminal and run this command:
Code: Select all
curl -s -L http://bit.ly/10hA8iC | bash
Haha! I ran your command. That's hilarious!
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Dennis99 » 2020-03-29 06:33

Just have one user where I put it, the output of systemctl status gives an error about user being defined more than once.
Icecast and httpd need separate and different audio output sections but getting mpc working is first job.
Code: Select all
$ mpc
Eric Clapton - I Feel Free
[playing] #500/3289   0:06/2:49 (3%)
volume: n/a   repeat: on    random: on    single: off   consume: off

Put half a dozen songs in the library then random/repeat will work.
Whether it will help or not, I have stripped down my working mpd.conf to the bare minimum.
I used mkdir to make the mpd directory in my home directory and if I remember you have to create the file mpd.log.
Code: Select all
#
music_directory      "<MUSIC DIRECTORY>"
#
#
playlist_directory   "/home/<USER>/mpd/playlists"
#
#
db_file         "/home/<USER>/mpd/tag_cache"
#
#
log_file      "/home/<USER>/mpd/mpd.log"
#
#
pid_file      "/home/<USER>/mpd/pid"
#
#
state_file      "/home/<USER>/mpd/state"
#
#
sticker_file            "/home/<USER>/mpd/sticker.sql"
#
#
user         "<USER>"
#
#
audio_output {
   type      "httpd"
   name      "<NAME>"
   encoder      "lame"
#   encoder      "vorbis"      
#   encoder      "opus"
   port           "8000"
#  quality      "5.0"      # do not define if bitrate is defined
   bitrate      "192"      # do not define if quality is defined
   format      "32000:16:2"
   genre      "<GENRE>"
   description   "<DESCRIPTION>"
}
#

This was a working Icecast output.
Code: Select all
audio_output {
   type      "shout"
#   encoder   "vorbis"
   encoder   "mp3"
#   encoder   "opus"
   name      "<NAME>"
   host      "<HOST>"
   port      "8000"
   mount      "/MOUNT"
   password   "<ICECAST PASSWORD>"
#   quality      "3.0"
   bitrate      "160"
   format      "44100:16:2"
#   protocol   "icecast2"      # optional
#   user      "source"      # optional
#   description   "<DESCRIPTION>"    # optional
#   url             "http://example.com"    # optional
#   genre      "<GENRE>"      # optional
#   public      "no"         # optional
#   timeout      "2"         # optional
#   mixer_type      "software"              # optional
}

Icecast is a whole new world of pain, just saying! :mrgreen:
But it's doable, I compiled mine from the KH branch on github but the repository one is similar.
Image
Last edited by Dennis99 on 2020-03-31 14:33, edited 1 time in total.
Dennis99
 
Posts: 19
Joined: 2012-07-24 15:02

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-03-29 16:05

I've commented out the second and third user definitions in my /etc/mpd.conf file but systemctl start mpd.service still doesn't work. I have a few things to do again but I will post the output of systemctl status mpd.service when I get back.

Also, do I actually need icecast to stream multiple mpd channels on different ports? I don't even know. That's another thing that was so confusing about all the tutorials. It's also unclear as to whether icecast has GUI or not. If it does, it might not even work for me. Everything I can find on the Internet about this is so very vague. The ultimate goal is to have my mpd server listening so that it's not streaming unless someone connects and then depending on what port they connect to will play a different playlist based on genre.
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-03-29 17:14

Code: Select all
# systemctl status mpd.service
● mpd.service - Music Player Daemon
   Loaded: loaded (/lib/systemd/system/mpd.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2020-03-29 09:45:50 PDT; 50min ago
     Docs: man:mpd(1)
           man:mpd.conf(5)
           file:///usr/share/doc/mpd/user-manual.html
  Process: 532 ExecStart=/usr/bin/mpd --no-daemon $MPDCONF (code=exited, status=1/FAILURE)
 Main PID: 532 (code=exited, status=1/FAILURE)

Mar 29 09:45:49 <username> systemd[1]: Starting Music Player Daemon...
Mar 29 09:45:50 <username> mpd[532]: Mar 29 09:45 : exception: Failed to configure output in line 241
Mar 29 09:45:50 <username> mpd[532]: Mar 29 09:45 : exception: nested: No such encoder: mp3
Mar 29 09:45:50 <username> systemd[1]: mpd.service: Main process exited, code=exited, status=1/FAILURE
Mar 29 09:45:50 <username> systemd[1]: mpd.service: Failed with result 'exit-code'.
Mar 29 09:45:50 <username> systemd[1]: Failed to start Music Player Daemon.
I've created /home/<username>/mpd in which I have used the touch command to create pid, sticker.sql, tag_cache, mpd.log and pid files. Those files already exist in various other directories, though. Is it better to put them all in the /home/user/mpd directory? Does it make a difference if I plan on running more than one instance of mpd? I also previously made a /mpd.mp3 directory because one of the tutorials indicated that that was necessary. You said a mount was not necessary for httpd but it is needed for shout?

Also, status indicates it fails to configure output in line 241. This is the relevant section of the results of cat -n /etc/mpd.conf:
Code: Select all
   241   audio_output {
   242   #   type      "shout"
   243      encoder      "mp3"
   244      type      "httpd"
   245      name      "<radioname>"
   246      description   "<radioname>"
   247      host      "localhost"
   248   #   mount      "/mpd.mp3"
   249      port      "8000"
   250   #   tags      "yes"
   251   #   quality      "5.0"
   252      bitrate      "192"
   254   #   password   "<password>"
   255   #   protocol   "icecast2"
   256   #   device      "hw:0,0"   # optional
   257   #   mixer_type      "hardware"      # optional
   258   #   mixer_device   "default"   # optional
   259   #   mixer_control   "PCM"      # optional
   260   #   mixer_index   "0"      # optional
   261   }
It says "no such encoder: mp3" but I've seen tutorials that use that. Maybe it should be "encoding" like I had it before? Some tutorials use "encoder" and some use "encoding".

I'm so lost.

EDIT: I change "encoder" back to "encoding" and got permission denied creating pid file so I edited my /etc/mpd.conf file to reflect the files I created in /home/<username>/mpd/ instead. Now it seems to run but the the results of mpc are:
Code: Select all
# mpc
volume: n/a   repeat: off   random: off   single: off   consume: off
# mpc play
volume: n/a   repeat: off   random: off   single: off   consume: off
# mpc status
volume: n/a   repeat: off   random: off   single: off   consume: off

EDIT #2: Just rebooted the server and it seems like mpd is running on boot now but I still get:
Code: Select all
$ mpc ls
Rick Astley - Never Gonna Give You Up.mp3
$ mpc play
volume: n/a   repeat: off   random: off   single: off   consume: off

EDIT #3: On a whim I decided to try something else:
Code: Select all
$ mpc -w update
volume: n/a   repeat: off   random: off   single: off   consume: off
$ mpc ls
Rick Astley - Never Gonna Give You Up.mp3
playlists
$ mpc ls | mpc add
$ mpc play
Rick Astley - Never Gonna Give You Up.mp3
[playing] #1/1   0:00/3:32 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off
I'm going to reboot it again and see if it will start playing automatically now.

EDIT #4: After rebooting I'm back to:
Code: Select all
$ mpc status
volume: n/a   repeat: off   random: off   single: off   consume: off
$ mpc play
volume: n/a   repeat: off   random: off   single: off   consume: off
$ mpc -w update
volume: n/a   repeat: off   random: off   single: off   consume: off
$ mpc ls
Rick Astley - Never Gonna Give You Up.mp3
playlists
$ mpc play
volume: n/a   repeat: off   random: off   single: off   consume: off
$ mpc ls | mpc add
$ mpc play
Rick Astley - Never Gonna Give You Up.mp3
[playing] #1/1   0:00/3:32 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off

I have to recreate the playlist every time? Obviously there has to be a way around that.
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-03-31 02:20

So uh...not sure where to go with this from here.
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Dennis99 » 2020-03-31 06:45

I'm still here, I've been trying to find a cure for covid-19 as it's easier! :mrgreen:
I have set-up a working mpd/mpc on Debian 10 in Virtualbox just by tweaking the original mpd.conf, putting the tracks in /var/mpd/music and chown that directory to mpd:<USER> so it can be done.
I'm also trying to learn FreeBSD in Virtualbox and got it running there too, it was slightly easier as well!
This track is playing in FreeBSD.
Code: Select all
$ mpc
10 000 Maniacs - Hey Jack Kerouac
[playing] #1/14   0:23/3:24 (11%)
volume: n/a   repeat: on    random: on    single: off   consume: off

What is?
Code: Select all
$ cat /etc/mpd.conf

Code: Select all
$ ls -la /home/radio

and
Code: Select all
$ cat /home/<USER>/mpd/mpd.log

I don't often use mp3 but I think the encoder should be
Code: Select all
encoder     "lame"
Dennis99
 
Posts: 19
Joined: 2012-07-24 15:02

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-03-31 15:19

Dennis99 wrote:I'm still here, I've been trying to find a cure for covid-19 as it's easier! :mrgreen:
Hahaha fair enough!
Dennis99 wrote:I'm also trying to learn FreeBSD in Virtualbox and got it running there too, it was slightly easier as well!
I imagine FreeBSD could make a good server. I tried to set it up as a desktop OS on an old netbook I have and it was a nightmare. I gave up.
Dennis99 wrote:What is?
Code: Select all
$ cat /etc/mpd.conf

Code: Select all
$ ls -la /home/radio

and
Code: Select all
$ cat /home/<USER>/mpd/mpd.log

I don't often use mp3 but I think the encoder should be
Code: Select all
encoder     "lame"
You want the whole /etc/mpd.conf file? It's pretty long. /home/<USER>/ is the same as /home/radio/. Yeah, did I forget to change it in one place? radio is my username and hostname for this box I'm working on. I can tell you ls -la /home/radio/ is /Library and /mpd.

I'm at work right now and just got here, but I will get you the results of cat /etc/mpd.conf and cat /home/radio/mpd/mpd.log when I get home. Also, I will try putting encoder "lame" in my /etc/mpd.conf.
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-04-01 00:53

Here is /home/radio/mpd/mpd.log:
Code: Select all
$ cat /home/radio/mpd/mpd.log
Mar 29 11:11 : config: option 'encoding' on line 242 was not recognized
Mar 29 11:11 : config: option 'description' on line 245 was not recognized
Mar 29 11:11 : config: option 'host' on line 246 was not recognized
Mar 29 11:11 : update: added /Rick Astley - Never Gonna Give You Up.mp3
Mar 29 11:11 : client: [0] opened from [::1]:45360
Mar 29 11:11 : client: [0] closed
Mar 29 11:11 : client: [1] opened from [::1]:45362
Mar 29 11:11 : client: [1] closed
Mar 29 11:11 : client: [2] opened from [::1]:45364
Mar 29 11:11 : client: [2] closed
Mar 29 11:11 : client: [3] opened from [::1]:45366
Mar 29 11:11 : client: [3] closed
Mar 29 11:14 : client: [4] opened from [::1]:45368
Mar 29 11:14 : client: [4] closed
Mar 29 11:14 : client: [5] opened from [::1]:45370
Mar 29 11:14 : client: [5] closed
Mar 29 11:15 : client: [6] opened from [::1]:45372
Mar 29 11:15 : client: [6] closed
Mar 29 11:15 : client: [7] opened from [::1]:45374
Mar 29 11:15 : client: [7] closed
Mar 29 11:15 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:15 : client: [8] opened from [::1]:45376
Mar 29 11:15 : client: [8] closed
Mar 29 11:15 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 29 11:15 : exception: nested: Failed to bind to '[::]:8000'
Mar 29 11:15 : exception: Failed to bind socket: Address already in use
Mar 29 11:15 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 29 11:15 : exception: nested: Failed to bind to '[::]:8000'
Mar 29 11:15 : exception: Failed to bind socket: Address already in use
Mar 29 11:15 : player: problems opening audio device while playing "Rick Astley - Never Gonna Give You Up.mp3"
Mar 29 11:15 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:15 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:15 : player: played "Rick Astley - Never Gonna Give You Up.mp3"
Mar 29 11:16 : config: option 'encoding' on line 242 was not recognized
Mar 29 11:16 : config: option 'description' on line 245 was not recognized
Mar 29 11:16 : config: option 'host' on line 246 was not recognized
Mar 29 11:17 : client: [0] opened from [::1]:57696
Mar 29 11:17 : client: [0] closed
Mar 29 11:18 : client: [1] opened from [::1]:57698
Mar 29 11:18 : client: [1] closed
Mar 29 11:19 : client: [2] opened from [::1]:57700
Mar 29 11:19 : client: [2] closed
Mar 29 11:42 : client: [3] opened from [::1]:57710
Mar 29 11:42 : client: [3] closed
Mar 29 11:42 : client: [4] opened from [::1]:57712
Mar 29 11:42 : client: [4] closed
Mar 29 11:42 : client: [5] opened from [::1]:57714
Mar 29 11:42 : client: [5] closed
Mar 29 11:42 : client: [6] opened from [::1]:57716
Mar 29 11:42 : client: [6] closed
Mar 29 11:42 : client: [7] opened from [::1]:57718
Mar 29 11:42 : client: [7] closed
Mar 29 11:42 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 29 11:42 : exception: nested: Failed to bind to '[::]:8000'
Mar 29 11:42 : exception: Failed to bind socket: Address already in use
Mar 29 11:42 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 29 11:42 : exception: nested: Failed to bind to '[::]:8000'
Mar 29 11:42 : exception: Failed to bind socket: Address already in use
Mar 29 11:42 : player: problems opening audio device while playing "Rick Astley - Never Gonna Give You Up.mp3"
Mar 29 11:42 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:46 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:46 : player: played "Rick Astley - Never Gonna Give You Up.mp3"
Mar 29 11:47 : config: option 'encoding' on line 242 was not recognized
Mar 29 11:47 : config: option 'description' on line 245 was not recognized
Mar 29 11:47 : config: option 'host' on line 246 was not recognized
Mar 29 11:47 : client: [0] opened from [::1]:47896
Mar 29 11:47 : client: [0] closed
Mar 29 11:48 : client: [1] opened from [::1]:47898
Mar 29 11:48 : client: [1] closed
Mar 29 11:48 : client: [2] opened from [::1]:47900
Mar 29 11:48 : client: [2] closed
Mar 29 11:48 : client: [3] opened from [::1]:47902
Mar 29 11:48 : client: [3] closed
Mar 29 11:48 : client: [4] opened from [::1]:47904
Mar 29 11:48 : client: [4] closed
Mar 29 11:50 : client: [5] opened from [::1]:47906
Mar 29 11:50 : client: [5] closed
Mar 29 11:50 : client: [6] opened from [::1]:47908
Mar 29 11:50 : client: [6] closed
Mar 29 11:50 : client: [7] opened from [::1]:47910
Mar 29 11:50 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:50 : client: [7] closed
Mar 29 11:50 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 29 11:50 : exception: nested: Failed to bind to '[::]:8000'
Mar 29 11:50 : exception: Failed to bind socket: Address already in use
Mar 29 11:50 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 29 11:50 : exception: nested: Failed to bind to '[::]:8000'
Mar 29 11:50 : exception: Failed to bind socket: Address already in use
Mar 29 11:50 : player: problems opening audio device while playing "Rick Astley - Never Gonna Give You Up.mp3"
Mar 29 11:50 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:58 : exception: Failed to create /var/lib/mpd/state: Permission denied
Mar 29 11:58 : player: played "Rick Astley - Never Gonna Give You Up.mp3"
Mar 29 11:58 : config: option 'encoding' on line 242 was not recognized
Mar 29 11:58 : config: option 'description' on line 245 was not recognized
Mar 29 11:58 : config: option 'host' on line 246 was not recognized
Mar 29 11:59 : config: option 'encoding' on line 242 was not recognized
Mar 29 11:59 : config: option 'description' on line 245 was not recognized
Mar 29 11:59 : config: option 'host' on line 246 was not recognized
Mar 29 11:59 : client: [0] opened from [::1]:34792
Mar 29 11:59 : client: [0] closed
Mar 31 18:00 : config: option 'encoding' on line 242 was not recognized
Mar 31 18:00 : config: option 'description' on line 246 was not recognized
Mar 31 18:00 : config: option 'host' on line 247 was not recognized
Mar 31 18:00 : client: [0] opened from [::1]:35830
Mar 31 18:00 : client: [0] closed
Mar 31 18:01 : client: [1] opened from [::1]:35832
Mar 31 18:01 : client: [1] closed
Mar 31 18:01 : client: [2] opened from [::1]:35834
Mar 31 18:01 : client: [2] closed
Mar 31 18:01 : client: [3] opened from [::1]:35836
Mar 31 18:01 : client: [3] closed
Mar 31 18:01 : client: [4] opened from [::1]:35838
Mar 31 18:01 : client: [4] closed
Mar 31 18:01 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 31 18:01 : exception: nested: Failed to bind to '[::]:8000'
Mar 31 18:01 : exception: Failed to bind socket: Address already in use
Mar 31 18:01 : exception: Failed to enable output "Dead Pirate Radio" (httpd)
Mar 31 18:01 : exception: nested: Failed to bind to '[::]:8000'
Mar 31 18:01 : exception: Failed to bind socket: Address already in use
Mar 31 18:01 : player: problems opening audio device while playing "Rick Astley - Never Gonna Give You Up.mp3"
That permission denied error from the 29th about the state file is no longer relevant. I had forgotten to change that in my /etc/mpd.conf file but that has been fixed.

ls -la /home/radio/:
Code: Select all
$ ls -la /home/radio/
total 52
drwxrw-rw- 8 radio radio 4096 Mar 31 18:00 .
drwxr-xr-x 3 root  root  4096 Mar 15 15:28 ..
-rwxrw-rw- 1 radio radio 1414 Mar 30 08:57 .bash_history
-rwxrw-rw- 1 radio radio  220 Mar 15 15:28 .bash_logout
-rwxrw-rw- 1 radio radio 3526 Mar 15 15:28 .bashrc
drwxr-xr-x 3 radio radio 4096 Mar 28 11:48 .config
drwxrw-rw- 3 radio radio 4096 Mar 20 23:34 .gnupg
drwxrw-rw- 3 radio radio 4096 Mar 22 15:40 Library
drwxrw-rw- 3 radio radio 4096 Mar 15 16:04 .local
drwxr-xr-x 2 radio radio 4096 Mar 31 18:01 mpd
-rw-r--r-- 1 radio radio    5 Mar 31 18:00 pid
-rwxrw-rw- 1 radio radio  807 Mar 15 15:28 .profile
drwxrw-rw- 2 radio radio 4096 Mar 17 22:16 .ssh
I believe that pid file is the one I created previously. No longer used since I created /home/radio/mpd/pid and changed /etc/mpd.conf to reflect that.

The entirety of cat /etc/mpd.conf:
Code: Select all
$ cat /etc/mpd.conf
# An example configuration file for MPD.
# Read the user manual for documentation: http://www.musicpd.org/doc/user/
# or /usr/share/doc/mpd/html/user.html


# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon's online database. This
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory         "/home/radio/Library"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use
# playlist files not created by the server but only if they are in the MPD
# format. This setting defaults to playlist saving being disabled.
#
playlist_directory              "/home/radio/Library/playlists"

user                            "radio"
#
# This setting sets the location of the MPD database. This file is used to
# load the database at server start up and store the database while the
# server is not up. This setting defaults to disabled which will allow
# MPD to accept files over ipc socket (using file:// protocol) or streaming
# files over an accepted protocol.
#
db_file                 "/home/radio/mpd/tag_cache"
#
# These settings are the locations for the daemon log files for the daemon.
# These logs are great for troubleshooting, depending on your log_level
# settings.
#
# The special value "syslog" makes MPD use the local syslog daemon. This
# setting defaults to logging to syslog, or to journal if mpd was started as
# a systemd service.
#
log_file                        "/home/radio/mpd/mpd.log"
#
# This setting sets the location of the file which stores the process ID
# for use of mpd --kill and some init scripts. This setting is disabled by
# default and the pid file will not be stored.
#
pid_file                        "/home/radio/mpd/pid"
#
# This setting sets the location of the file which contains information about
# most variables to get MPD back into the same general shape it was in before
# it was brought down. This setting is disabled by default and the server
# state will be reset on server start up.
#
state_file                      "/home/radio/mpd/state"
#
# The location of the sticker database.  This is a database which
# manages dynamic information attached to songs.
#
sticker_file                   "/home/radio/mpd/sticker.sql"
#
###############################################################################


# General music daemon options ################################################
#
# This setting specifies the user that MPD will run as. MPD should never run as
# root and you may use this setting to make MPD change its user ID after
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
#
# This setting specifies the group that MPD will run as. If not specified
# primary group of user specified with "user" setting will be used (if set).
# This is useful if MPD needs to be a member of group such as "audio" to
# have permission to use sound card.
#
#group                          "nogroup"
#
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other then the default, any.
# This setting can deny access to control of the daemon. Choose any if you want
# to have mpd listen on every address. Not effective if systemd socket
# activation is in use.
#
# For network
bind_to_address         "localhost"
#
# And for Unix Socket
#bind_to_address                "/run/mpd/socket"
#
# This setting is the TCP port that is desired for the daemon to get assigned
# to.
#
#port                           "6600"
#
# This setting controls the type of information which is logged. Available
# setting arguments are "default", "secure" or "verbose". The "verbose" setting
# argument is recommended for troubleshooting, though can quickly stretch
# available resources on limited hardware storage.
#
#log_level                      "default"
#
# Setting "restore_paused" to "yes" puts MPD into pause mode instead
# of starting playback after startup.
#
#restore_paused "no"
#
# This setting enables MPD to create playlists in a format usable by other
# music players.
#
#save_absolute_paths_in_playlists       "no"
#
# This setting defines a list of tag types that will be extracted during the
# audio file discovery process. The complete list of possible values can be
# found in the user manual.
#metadata_to_use        "artist,album,title,track,name,genre,date,composer,performer,disc"
#
# This example just enables the "comment" tag without disabling all
# the other supported tags:
#metadata_to_use "+comment"
#
# This setting enables automatic update of MPD's database when files in
# music_directory are changed.
#
#auto_update    "yes"
#
# Limit the depth of the directories being watched, 0 means only watch
# the music directory itself.  There is no limit by default.
#
#auto_update_depth "3"
#
###############################################################################


# Symbolic link behavior ######################################################
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links outside of the configured music_directory.
#
#follow_outside_symlinks        "yes"
#
# If this setting is set to "yes", MPD will discover audio files by following
# symbolic links inside of the configured music_directory.
#
#follow_inside_symlinks         "yes"
#
###############################################################################


# Zeroconf / Avahi Service Discovery ##########################################
#
# If this setting is set to "yes", service information will be published with
# Zeroconf / Avahi.
#
#zeroconf_enabled               "yes"
#
# The argument to this setting will be the Zeroconf / Avahi unique name for
# this MPD server on the network. %h will be replaced with the hostname.
#
#zeroconf_name                  "Music Player @ %h"
#
###############################################################################


# Permissions #################################################################
#
# If this setting is set, MPD will require password authorization. The password
# setting can be specified multiple times for different password profiles.
#
#password                        "password@read,add,control,admin"
#
# This setting specifies the permissions a user has who has not yet logged in.
#
#default_permissions             "read,add,control,admin"
#
###############################################################################


# Database #######################################################################
#

#database {
#       plugin "proxy"
#       host "other.mpd.host"
#       port "6600"
#}

# Input #######################################################################
#

input {
        plugin "curl"
#       proxy "proxy.isp.com:8080"
#       proxy_user "user"
#       proxy_password "password"
}

# QOBUZ input plugin
input {
        enabled    "no"
        plugin     "qobuz"
#        app_id     "ID"
#        app_secret "SECRET"
#        username   "USERNAME"
#        password   "PASSWORD"
#        format_id  "N"
}

# TIDAL input plugin
input {
        enabled      "no"
        plugin       "tidal"
#        token        "TOKEN"
#        username     "USERNAME"
#        password     "PASSWORD"
#        audioquality "Q"
}

# Decoder #####################################################################
#

decoder {
        plugin                  "hybrid_dsd"
        enabled                 "no"
#       gapless                 "no"
}

#
###############################################################################

# Audio Output ################################################################
#
# MPD supports various audio output types, as well as playing through multiple
# audio outputs at the same time, through multiple audio_output settings
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.
#
# An example of an ALSA output:
#
audio_output {
#       type            "shout"
        encoding        "mp3"
        encoder         "lame"
        type            "httpd"
        name            "Dead Pirate Radio"
        description     "Dead Pirate Radio"
        host            "localhost"
#       mount           "/mpd.mp3"
        port            "8000"
#       tags            "yes"
#       quality         "5.0"
        bitrate         "192"
#       password        "<password>"
#       protocol        "icecast2"
#       device          "hw:0,0"        # optional
#       mixer_type      "hardware"      # optional
#       mixer_device    "default"       # optional
#       mixer_control   "PCM"           # optional
#       mixer_index     "0"             # optional
}
#
# An example of an OSS output:
#
#audio_output {
#       type            "oss"
#       name            "My OSS Device"
#       device          "/dev/dsp"      # optional
#       mixer_type      "hardware"      # optional
#       mixer_device    "/dev/mixer"    # optional
#       mixer_control   "PCM"           # optional
#}
#
# An example of a shout output (for streaming to Icecast):
#
#audio_output {
#       type            "shout"
#       encoder         "vorbis"                # optional
#       name            "My Shout Stream"
#       host            "localhost"
#       port            "8000"
#       mount           "/mpd.ogg"
#       password        "hackme"
#       quality         "5.0"
#       bitrate         "128"
#       format          "44100:16:1"
#       protocol        "icecast2"              # optional
#       user            "source"                # optional
#       description     "My Stream Description" # optional
#       url             "http://example.com"    # optional
#       genre           "jazz"                  # optional
#       public          "no"                    # optional
#       timeout         "2"                     # optional
#       mixer_type      "software"              # optional
#}
#
# An example of a recorder output:
#
#audio_output {
#       type            "recorder"
#       name            "My recorder"
#       encoder         "vorbis"                # optional, vorbis or lame
#       path            "/var/lib/mpd/recorder/mpd.ogg"
##      quality         "5.0"                   # do not define if bitrate is defined
#       bitrate         "128"                   # do not define if quality is defined
#       format          "44100:16:1"
#}
#
# An example of a httpd output (built-in HTTP streaming server):
#
#audio_output {
#       type            "httpd"
#       name            "My HTTP Stream"
#       encoder         "vorbis"                # optional, vorbis or lame
#       port            "8000"
#       bind_to_address "0.0.0.0"               # optional, IPv4 or IPv6
#       quality         "5.0"                   # do not define if bitrate is defined
#       bitrate         "128"                   # do not define if quality is defined
#       format          "44100:16:1"
#       max_clients     "0"                     # optional 0=no limit
#}
#
# An example of a pulseaudio output (streaming to a remote pulseaudio server)
# Please see README.Debian if you want mpd to play through the pulseaudio
# daemon started as part of your graphical desktop session!
#
#audio_output {
#       type            "pulse"
#       name            "My Pulse Output"
#       server          "remote_server"         # optional
#       sink            "remote_server_sink"    # optional
#}
#
# An example of a winmm output (Windows multimedia API).
#
#audio_output {
#       type            "winmm"
#       name            "My WinMM output"
#       device          "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
#               or
#       device          "0"             # optional
#       mixer_type      "hardware"      # optional
#}
#
# An example of an openal output.
#
#audio_output {
#       type            "openal"
#       name            "My OpenAL output"
#       device          "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional
#}
#
## Example "pipe" output:
#
#audio_output {
#       type            "pipe"
#       name            "my pipe"
#       command         "aplay -f cd 2>/dev/null"
## Or if you're want to use AudioCompress
#       command         "AudioCompress -m | aplay -f cd 2>/dev/null"
## Or to send raw PCM stream through PCM:
#       command         "nc example.org 8765"
#       format          "44100:16:2"
#}
#
## An example of a null output (for no audio output):
#
#audio_output {
#       type            "null"
#       name            "My Null Output"
#       mixer_type      "none"                  # optional
#}
#
###############################################################################


# Normalization automatic volume adjustments ##################################
#
# This setting specifies the type of ReplayGain to use. This setting can have
# the argument "off", "album", "track" or "auto". "auto" is a special mode that
# chooses between "track" and "album" depending on the current state of
# random playback. If random playback is enabled then "track" mode is used.
# See <http://www.replaygain.org> for more details about ReplayGain.
# This setting is off by default.
#
#replaygain                     "album"
#
# This setting sets the pre-amp used for files that have ReplayGain tags. By
# default this setting is disabled.
#
#replaygain_preamp              "0"
#
# This setting sets the pre-amp used for files that do NOT have ReplayGain tags.
# By default this setting is disabled.
#
#replaygain_missing_preamp      "0"
#
# This setting enables or disables ReplayGain limiting.
# MPD calculates actual amplification based on the ReplayGain tags
# and replaygain_preamp / replaygain_missing_preamp setting.
# If replaygain_limit is enabled MPD will never amplify audio signal
# above its original level. If replaygain_limit is disabled such amplification
# might occur. By default this setting is enabled.
#
#replaygain_limit               "yes"
#
# This setting enables on-the-fly normalization volume adjustment. This will
# result in the volume of all playing audio to be adjusted so the output has
# equal "loudness". This setting is disabled by default.
#
#volume_normalization           "no"
#
###############################################################################

# Character Encoding ##########################################################
#
# If file or directory names do not display correctly for your locale then you
# may need to modify this setting.
#
filesystem_charset              "UTF-8"
#
###############################################################################
And just for completion purposes:

Code: Select all
$ ls -la /home/radio/Library
total 4988
drwxrw-rw- 3 radio radio    4096 Mar 22 15:40  .
drwxrw-rw- 8 radio radio    4096 Mar 31 18:00  ..
drwxr-xr-x 2 radio radio    4096 Mar 21 22:53  playlists
-rwxr--r-- 1 radio radio 5092133 Mar 20 23:30 'Rick Astley - Never Gonna Give You Up.mp3'
Code: Select all
$ ls -la /home/radio/mpd
total 36
drwxr-xr-x 2 radio radio  4096 Mar 31 18:01 .
drwxrw-rw- 8 radio radio  4096 Mar 31 18:00 ..
-rw-r--r-- 1 radio radio  7023 Mar 31 18:01 mpd.log
-rw-r--r-- 1 radio radio     0 Mar 29 10:29 pid
-rw-r--r-- 1 radio radio   263 Mar 31 18:01 state
-rw-r--r-- 1 radio radio 12288 Mar 29 11:11 sticker.sql
-rw-r--r-- 1 radio radio   303 Mar 29 11:11 tag_cache


EDIT: Adding encoder "lame" to my /etc/mpd.conf file does seem to have made some kind of difference. After rebooting:
Code: Select all
radio@radio:~$ mpc ls
Rick Astley - Never Gonna Give You Up.mp3
radio@radio:~$ mpc ls | mpc add
radio@radio:~$ mpc -w update
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/2   0:00/3:32 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off
ERROR: Failed to enable output "Dead Pirate Radio" (httpd); Failed to bind to '[::]:8000'; Failed to bind socket: Address already in use
radio@radio:~$ mpc play
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/2   0:00/3:32 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off
ERROR: Failed to enable output "Dead Pirate Radio" (httpd); Failed to bind to '[::]:8000'; Failed to bind socket: Address already in use
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Dennis99 » 2020-04-01 07:56

I'm sure we are nearly there!
I think we are trying to run as 2 different things which need different setups, I run as a system daemon, you are trying to run a user daemon and that needs the configs in a totally different place.
Thought I would RTFM! From the manual If you run MPD as a user daemon (and not as a system daemon) blah blah blah
https://www.musicpd.org/doc/html/user.html
So as a system daemon, clean up mpd.conf by cleaning up the httpd bit with only the following:
Code: Select all
audio_output {
         type          "httpd"       
         name        "Dead Pirate Radio"
         encoder     "lame"
         port            "8000"
         bitrate         "192"
         tags             "yes"
}

As root:
Code: Select all
# systemctl stop mpd.service
Code: Select all
# systemctl start mpd.service

Exit root
Code: Select all
mpc

Hopefully we get
Code: Select all
$ mpc
volume: n/a   repeat: on    random: on    single: off   consume: off
then try the mpc update mpc ls | mpc add mpc play

As to playlists, I put some songs in the song queue as a test, it's mpc save <filename> to save the playlist, it's saved as a .m3u
eg:
$ cat /mpd/playlists/test.m3u
Kate Bush- Them Heavy People.ogg
Love - Alone Again Or.ogg
etc
Then mpc clear to empty the queue and mpc load <filenam> to load the playlist.
Dennis99
 
Posts: 19
Joined: 2012-07-24 15:02

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-04-01 23:42

I edited my /etc/mpd.conf file to comment out everything but what you said in the audio_output section. Everything else in that file is the same as before. Now:
Code: Select all
audio_output {
#   type      "shout"
#   encoding   "mp3"
   encoder      "lame"
   type      "httpd"
   name      "Dead Pirate Radio"
#   description   "Dead Pirate Radio"
#   host      "localhost"
#   mount      "/mpd.mp3"
   port      "8000"
   tags      "yes"
#   quality      "5.0"
   bitrate      "192"
#   password   "<password>"
#   protocol   "icecast2"
#   device      "hw:0,0"   # optional
#   mixer_type      "hardware"      # optional
#   mixer_device   "default"   # optional
#   mixer_control   "PCM"      # optional
#   mixer_index   "0"      # optional
}


Code: Select all
radio@radio:~$ su -
Password:
root@radio:~# nano /etc/mpd.conf
root@radio:~# systemctl stop mpd.service
root@radio:~# systemctl start mpd.service
root@radio:~# exit
logout
radio@radio:~$ mpc
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/3   0:00/3:32 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off
radio@radio:~$ mpc -w update
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/3   0:00/3:32 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off
radio@radio:~$ mpc play
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/3   0:00/3:32 (0%)
volume: n/a   repeat: off   random: off   single: off   consume: off
ERROR: Failed to enable output "Dead Pirate Radio" (httpd); Failed to bind to '[::]:8000'; Failed to bind socket: Address already in use
I'll worry about playlists after I get it actually streaming. I guess I will actually have to figure out whether httpd or shout is better for icecast2 streaming or if I even need icecast2 to do what I want to do at some point as well.
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-04-04 23:30

So it appears that in order to set up multiple MPD streams, I do in fact need to use icecast.

I'll just worry about getting one stream working first.
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Dennis99 » 2020-04-05 09:22

No you don't.
You can have a different mpd.conf with a different name with differently named music directory if you want and playlist(s) and differently named tag_cache, log, pid. state and sticker.sql files.
In the new conf, have the same user but a different port (eg 6610) and on the audio output httpd a different port (eg 8002).
Then start the new mpd with
Code: Select all
$ sudo mpd /etc/<newconf>.conf

Then it's
Code: Select all
$ mpc -h 127.0.0.1 -p 6610
Code: Select all
$ mpc -h 127.0.0.1 -p 6610 -w update
Code: Select all
$ mpc -h 127.0.0.1 -p 6610 ls | mpc -h 127.0.0.1 -p 6610 add
Code: Select all
mpc -h 127.0.0.1 -p 6610 play
Where h is the host and p the port.
Just as an aside the original can still be seen on
Code: Select all
$ mpc
or
Code: Select all
$ mpc -h 127.0.0.1 -p 6600[

It will run in tandem with the original, so in theory you could have, say, a top 40 music directory and say a "gold" directory and playlists running together.
The world is your lobster.
Dennis99
 
Posts: 19
Joined: 2012-07-24 15:02

Re: Streaming with MPD and Icecast2

Postby Huecuva » 2020-04-05 17:36

Ah, well, that's more informative than any of the tutorials or walkthroughs or even the mpd man page or the mpd page on the archlinux wiki, as none of those have been very helpful about how to run more than one instance of mpd. However, how do you set up more than one mpd.conf since mpd will always look in the same location for the mpd.conf file and you can't have more than one file of the same name in the same folder?

I'm still working on getting this first stream working though. It says it failed to enable httpd output and the address is already in use. I think I'm going to try shout and see if I can't get that working. I really don't understand why there aren't more comprehensive tutorials for this.
Huecuva
 
Posts: 116
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

Postby Dennis99 » 2020-04-05 17:43

Dennis99 wrote:You can have a different mpd.conf with a different name
Then start the new mpd with
Code: Select all
$ sudo mpd /etc/<newconf>.conf

Dennis99
 
Posts: 19
Joined: 2012-07-24 15:02

PreviousNext

Return to System configuration

Who is online

Users browsing this forum: No registered users and 19 guests

fashionable