Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

<SOLVED> Streaming with MPD and Icecast2

Linux Kernel, Network, and Services configuration.
Message
Author
Huecuva
Posts: 135
Joined: 2017-06-09 04:00

<SOLVED> Streaming with MPD and Icecast2

#1 Post by Huecuva »

Alright. I've finally gotten the network share working and a test file uploaded to the Library in my fit-PC. I've installed mpd and icecast2 as well as mpc, though I'm not sure if I need that or not. I've found a number of tutorials for this process but they vary widely and are very inconsistent and often also very old. I don't know what I need to add to /etc/mpd.conf or /etc/icecast2/icecast.xml and what I don't need to add to those files.

Ultimately, I want to be able to stream multiple instances of mpd on the same IP on different ports, so a user could put my IP address and a port number into their music player and play a different stream based on whatever port they put in.

Some of the tutorials and walk-throughs I've looked at are:
https://wiki.debian.org/mpd
https://stmllr.net/blog/streaming-audio ... pberry-pi/
https://wiki.archlinux.org/index.php/Icecast
https://dev.to/djemos/how-to-setup-a-st ... tation-a2a
https://log.liminastudio.com/miscellane ... ast-as-mp3

As you can see, they're all very different. Some have the stream type set as "alsa" in the /etc/mpd.conf file and some have it set as "shout". I don't know that the difference is or which I should use.

Can someone shed some more light on this, please?
Last edited by Huecuva on 2020-04-11 19:35, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Streaming with MPD and Icecast2

#2 Post by Head_on_a_Stick »

Looks like you don't need icecast at all: https://wiki.archlinux.org/index.php/Mu ... _streaming

Disclaimer: I've never actually tried this.
deadbang

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#3 Post by Huecuva »

Hmmm. That's interesting.

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#4 Post by Huecuva »

Nobody else has any ideas about this?

My /etc/mpd.conf file contains:

Code: Select all

music_directory         "/home/radio/Library"
playlist_directory              "/home/radio/Library/playlists"

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"
        user            "<user>"
When I try to start the service:

Code: Select all

root@radio:~# service mpd start
Job for mpd.service failed because the control process exited with error code.
See "systemctl status mpd.service" and "journalctl -xe" for details.
root@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 Sun 2020-03-22 19:36:08 PDT; 48s ago
     Docs: man:mpd(1)
           man:mpd.conf(5)
           file:///usr/share/doc/mpd/user-manual.html
  Process: 648 ExecStart=/usr/bin/mpd --no-daemon $MPDCONF (code=exited, status=1/FAILURE)
 Main PID: 648 (code=exited, status=1/FAILURE)

Mar 22 19:36:07 radio systemd[1]: Starting Music Player Daemon...
Mar 22 19:36:08 radio mpd[648]: Mar 22 19:36 : exception: Failed to create pid file "/run/mpd/pid": Permission denied
Mar 22 19:36:08 radio systemd[1]: mpd.service: Main process exited, code=exited, status=1/FAILURE
Mar 22 19:36:08 radio systemd[1]: mpd.service: Failed with result 'exit-code'.
Mar 22 19:36:08 radio systemd[1]: Failed to start Music Player Daemon.
root@radio:~# journalctl -xe
-- The process' exit code is 'exited' and its exit status is 1.
Mar 22 19:34:59 radio 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 22 19:34:59 radio 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 700 and the job result is failed.
Mar 22 19:35:00 radio dhclient[385]: No DHCPOFFERS received.
Mar 22 19:35:00 radio dhclient[385]: No working leases in persistent database - sleeping.
Mar 22 19:35:00 radio root[624]: /etc/dhcp/dhclient-exit-hooks.d/zzz_avahi-autoipd returned non-zero exit status 1
Mar 22 19:36:07 radio 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 816.
Mar 22 19:36:08 radio mpd[648]: Mar 22 19:36 : exception: Failed to create pid file "/run/mpd/pid": Permission denied
Mar 22 19:36:08 radio 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 22 19:36:08 radio 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 22 19:36:08 radio 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 816 and the job result is failed.
After changing the ownership of /run/mpd/ to the radio user, I was able to start the service. I am still unable to connect to it, however. I have my router port forwarded to port 8000 for the IP of my fit-PC, but that is behind my room mate's modem/gateway. My router's IP address is configured as DMZ on his gateway. Does that even help?

Also, it appears that if the fit-PC ever reboots, the ownership of /run/mpd/ reverts back to root and the mpd fails to start. How do I fix that?

Code: Select all

root@radio:~# service mpd status
● 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-22 19:58:35 PDT; 32s ago
     Docs: man:mpd(1)
           man:mpd.conf(5)
           file:///usr/share/doc/mpd/user-manual.html
  Process: 454 ExecStart=/usr/bin/mpd --no-daemon $MPDCONF (code=exited, status=1/FAILURE)
 Main PID: 454 (code=exited, status=1/FAILURE)

Mar 22 19:58:30 radio systemd[1]: Starting Music Player Daemon...
Mar 22 19:58:35 radio mpd[454]: Mar 22 19:58 : exception: Failed to create pid file "/run/mpd/pid": Permission denied
Mar 22 19:58:35 radio systemd[1]: mpd.service: Main process exited, code=exited, status=1/FAILURE
Mar 22 19:58:35 radio systemd[1]: mpd.service: Failed with result 'exit-code'.
Mar 22 19:58:35 radio systemd[1]: Failed to start Music Player Daemon.
root@radio:~# service mpd start
Job for mpd.service failed because the control process exited with error code.
See "systemctl status mpd.service" and "journalctl -xe" for details.
root@radio:~# chown -R radio:radio /run/mpd/
root@radio:~# service mpd start
root@radio:~# service mpd status
● mpd.service - Music Player Daemon
   Loaded: loaded (/lib/systemd/system/mpd.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2020-03-22 20:00:00 PDT; 2s ago
     Docs: man:mpd(1)
           man:mpd.conf(5)
           file:///usr/share/doc/mpd/user-manual.html
 Main PID: 578 (mpd)
    Tasks: 3 (limit: 4915)
   Memory: 7.8M
   CGroup: /system.slice/mpd.service
           └─578 /usr/bin/mpd --no-daemon

Mar 22 19:59:59 radio systemd[1]: Starting Music Player Daemon...
Mar 22 20:00:00 radio systemd[1]: Started Music Player Daemon.

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#5 Post by Huecuva »

Well, I still haven't managed to get any further with this. While my router is set up as DMZ on my room mate's modem/gateway, I'm still not even able to connect to my streaming radio to see if it works.

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

Re: Streaming with MPD and Icecast2

#6 Post by Dennis99 »

First go back to basics to get mpc/mpd working locally.
I use mpd/mpc regularly so might be able to point the way.
To start in a terminal what output does mpc give?
It should look like:

Code: Select all

$ mpc
The Doobie Brothers - Feelin' Down Farther
[playing] #3013/3286   0:04/4:17 (1%)
volume: n/a   repeat: on    random: on    single: off   consume: off

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#7 Post by Huecuva »

Thank you, hopefully with your help I can finally get this working. I've been trying to get this figured out for years. Literally.

Code: Select all

$ mpc
volume: n/a   repeat: off   random: off   single: off   consume: off

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

Re: Streaming with MPD and Icecast2

#8 Post by Dennis99 »

Good, looks like mpd and mpc are running and talking to each other.
Next step, populate the database. Depending on how many tracks are in your library this may take a while. The -w makes it wait until it's finished.

Code: Select all

$ mpc -w update
Next, make a playlist, (lists the tracks and pipes (the | ) to a playlist)

Code: Select all

$ mpc ls | mpc add
Next:

Code: Select all

$ mpc play
What does that output?
To make the playlist randomly play for evermore.

Code: Select all

mpc random

Code: Select all

$ mpc repeat
Do all that to see if we can get output then we can move on.

The currently playing track here :D

Code: Select all

mpc
The Police - Walking on the Moon
[playing] #1412/3286   3:32/4:56 (71%)
volume: n/a   repeat: on    random: on    single: off   consume: off

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#9 Post by Huecuva »

I only have one track in my library right now, just for testing. I have a particular buddy who will get a big kick out of it when I get him to test this for me. Once I get it streaming, I plan on having multiple playlists on different ports.

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
$ 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
$ mpc random
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/1   0:00/3:32 (0%)
volume: n/a   repeat: off   random: on    single: off   consume: off
ERROR: Failed to enable output "My radio name" (httpd); Failed to bind to '[::]:8000'; Failed to bind socket: Address already in use
$ mpc repeat
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/1   0:00/3:32 (0%)
volume: n/a   repeat: on    random: on    single: off   consume: off
ERROR: Failed to enable output "My radio name" (httpd); Failed to bind to '[::]:8000'; Failed to bind socket: Address already in use
$ mpc
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/1   0:00/3:32 (0%)
volume: n/a   repeat: on    random: on    single: off   consume: off
ERROR: Failed to enable output "My radio name" (httpd); Failed to bind to '[::]:8000'; Failed to bind socket: Address already in use
$ mpc play
Rick Astley - Never Gonna Give You Up.mp3
[paused]  #1/1   0:00/3:32 (0%)
volume: n/a   repeat: on    random: on    single: off   consume: off
ERROR: Failed to enable output "My radio name" (httpd); Failed to bind to '[::]:8000'; Failed to bind socket: Address already in use
EDIT: I just tried rebooting my fit-PC and mpc no longer gives that output when I query it. I think the first order of business is making mpd run at boot. I did this:

Code: Select all

$ systemctl --user enable mpd
Created symlink /home/radio/.config/systemd/user/default.target.wants/mpd.service → /usr/lib/systemd/user/mpd.service.
But I still get:

Code: Select all

$ mpc
mpd error: Connection reset by peer
Last edited by Huecuva on 2020-03-28 18:04, edited 1 time in total.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Streaming with MPD and Icecast2

#10 Post by Head_on_a_Stick »

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
deadbang

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

Re: Streaming with MPD and Icecast2

#11 Post by Dennis99 »

Try

Code: Select all

$ sudo systemctl stop mpd.service

Code: Select all

$ sudo systemctl stop mpd.socket

Code: Select all

$ sudo systemctl disable mpd.socket
Then reboot.
EDIT: You may need to fiddle with your mpd.conf to get the correct user:

Code: Select all

# 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.
#
user				"YOUR_USER_NAME_HERE"
#
P.S If it's any consolation, it took me bloody ages to get mpd/mpc sorted when I started a few years ago!
The good news is I also use httpd output and I've had Icecast working nicely using mpd/mpc. :D

Current track:

Code: Select all

Massive Attack - Unfinished Sympathy
[playing] #1878/3286   1:42/5:02 (33%)
volume: n/a   repeat: on    random: on    single: off   consume: off
Last edited by Dennis99 on 2020-03-28 18:22, edited 4 times in total.

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#12 Post by Huecuva »

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
Heh. I dunno if I should trust that command now :)
Dennis99 wrote:Try

Code: Select all

$ sudo systemctl stop mpd.service

Code: Select all

$ sudo systemctl stop mpd.socket

Code: Select all

$ sudo systemctl disable mpd.socket
Then reboot.
I've edited my last comment. I don't know if that changes anything. I have to go run some errands right now, but I'll be back on this in a couple of hours and I will try what you suggest.

Thanks for the help so far, mate.

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

Re: Streaming with MPD and Icecast2

#13 Post by Dennis99 »

Huecuva wrote: Thanks for the help so far, mate.
No problem.
I don't know where you are in the world, but I'm on lock-down here in the UK and can only leave the house in exceptional circumstances or for one session of exercise per day which I use to walk my dogs.
I'm indoors 23 hours per day. :(

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#14 Post by Huecuva »

Dennis99 wrote:
Huecuva wrote: Thanks for the help so far, mate.
No problem.
I don't know where you are in the world, but I'm on lock-down here in the UK and can only leave the house in exceptional circumstances or for one session of exercise per day which I use to walk my dogs.
I'm indoors 23 hours per day. :(
I'm in western Canada. A lot of my area is shut down too, but some stuff is still open. Had to get the winter tires off my car. I'm back now though. Gonna try your suggestions in a few here.

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#15 Post by Huecuva »

Code: Select all

# systemctl stop mpd.service
# systemctl stop mpd.socket
# systemctl disable mpd.socket
Removed /etc/systemd/system/sockets.target.wants/mpd.socket.
# reboot

Code: Select all

$ mpc
mpd error: Connection refused
I do have user "myusernamehere" in my audio_output section. Does it need to be elsewhere?
Last edited by Huecuva on 2020-03-28 22:47, edited 5 times in total.

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

Re: Streaming with MPD and Icecast2

#16 Post by Dennis99 »

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

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#17 Post by Huecuva »

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!

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

Re: Streaming with MPD and Icecast2

#18 Post by Dennis99 »

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.

Huecuva
Posts: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#19 Post by Huecuva »

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: 135
Joined: 2017-06-09 04:00

Re: Streaming with MPD and Icecast2

#20 Post by Huecuva »

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.

Post Reply