hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

MPD and high CPU usage

Mon Jun 17, 2013 11:27 pm

Wondering if anyone can help point me at how to reduce the CPU load with MPD please.

My Pi is running latest raspbian, headless through wired ethernet with a USB hard drive containing my music library. The files are shared with samba and also I have MPD running an icecast stream. The icecast stream is the only audio output. No matter what I try MPD uses between 50% and 60% which seems ridiculously high. Every so often I get a pause in the MPD stream of several seconds - not sure if this is a result of the CPU load or not.

Would appreciate any pointers, thanks.

ascent
Posts: 3
Joined: Sat Jun 29, 2013 11:45 am

Re: MPD and high CPU usage

Sat Jun 29, 2013 12:25 pm

Hi,

Same here, I think it's due to the fact that mpd re-encodes all the music. I've been trying to switch back and forth between ogg and mp3 but no change. Some tutorials on the internet suggest switching to the httpd output, instead of icecast, but that's ofcourse less "cool" ;-)

Using httpd output combined with FLAC further reduces the load but increases the network traffic.

I'm still looking for a way to stop mpd from re-encoding my media as most of it is mp3 anyway.

Did you find anything in the meanwhile?

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Sat Jun 29, 2013 2:50 pm

Nothing yet - tried everything I can think of but no joy :(

I wondered if there is something in the sound configuration but my skills are a bit too limited :) . I switched between alsa and pulse audio but that made no significant difference. In itself, high CPU is not an issue - however frequent 10 second pauses in music playback really make the pi unusable in the way I would like. It may be though that these pauses are caused by the USB and network interfaces competing for resources? I hoped that solving the MPD issue would make the pauses go away.

I am frustrated by my lack of ability to fix this - especially after just discovering MPD/Icecast and having high hopes for these with the pi. Such a combination of low power consumption, from a low cost device, with flexible open source sw is still my aim!

belthazar7
Posts: 1
Joined: Sun Jun 30, 2013 9:53 am

Re: MPD and high CPU usage

Sun Jun 30, 2013 9:20 pm

Hi,
I am also trying to set up a streaming mpd server.
I was going for the http stream, and by changing the fixed 128bit to quality 5.0, I reduced cpu load from 90% to 40%.
So far so good, the stream has a lag from 40sec to a minute , and this seems to add up with each song,
so of course there is a looong break between songs . . .
which renders it unusable.
Has anyone an idea to improve this ?
Is this any better with icecast ?

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Sun Jun 30, 2013 9:29 pm

@ belthazar7

Icecast was better for me than that - the pauses tended to be consistently around 5-10 seconds, but the effect was not cumulative. The pauses were on average no more than once per song. So at least from my experience icecast was less problematic. I tried different quality settings as well but that made no big difference.

ascent
Posts: 3
Joined: Sat Jun 29, 2013 11:45 am

Re: MPD and high CPU usage

Sun Jun 30, 2013 9:33 pm

Perhaps a strange idea, but could it be that things improve when we use darkice to fetch the alsa stream and use darkice to pass the stream to icecast? Perhaps farfetched, but maybe it works..

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Sun Jun 30, 2013 9:40 pm

Please try it and post the results - I am out of better ideas :)

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: MPD and high CPU usage

Tue Jul 02, 2013 11:30 am

hooliganshark wrote:Please try it and post the results - I am out of better ideas :)
What fixed it for me:-

In mpd.conf:-

Code: Select all

# An example of a httpd output (built-in HTTP streaming server):
#        
audio_output {
        type            "httpd"
        name            "My  HTTP Stream"
        encoder         "flac"          # optional, vorbis or lame
#       bind_to_address "localhost"
        port            "1234"
#       quality         "5.0"                   # do not define if bitrate is defined
#       bitrate         "256"                   # do not define if quality is defined
        format          "44100:16:2"
In other words, use flac encoding, works a dream.
I have 4 simultaneous streams running on my Pi. (4 mpd's running)
Even run TV using TVheadend. No cpu probs.
Music & TV even streams to a 3g connected phone. :D :D
Have fun! :)

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Tue Jul 02, 2013 11:50 am

Many thanks, I will try this out as soon as I can.

May I ask for a few more details of your setup please?

-what format is the music stored in? I assume flac? (All my music is in flac). AFAIK Icecast only supports mp3 or ogg, so http would also suit me if this eliminates the transcoding overhead.
-where is your music stored? Is it on a local drive connected on usb, and if so, is it powered from a hub or an independent supply?
-are you using wifi or wired network connection?

Thanks for your help.

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: MPD and high CPU usage

Tue Jul 02, 2013 12:13 pm

hooliganshark wrote:Many thanks, I will try this out as soon as I can.

May I ask for a few more details of your setup please?

-what format is the music stored in? I assume flac? (All my music is in flac). AFAIK Icecast only supports mp3 or ogg, so http would also suit me if this eliminates the transcoding overhead.
-where is your music stored? Is it on a local drive connected on usb, and if so, is it powered from a hub or an independent supply?
-are you using wifi or wired network connection?

Thanks for your help.
My music is stored in varied formats, mostly vorbis ogg, also flac, *.flv (m4A) very little mp3. My setup seems to play anything! All my media (audio
,downloaded radio & tv progs & tvheadend recording) is stored on a usb
connected 1tb local drive, with independent power supply.
I am using wifi. No latency problems. It all works absolutely beyond
my wildest expectations! I also run apache2 webserver. And use the Pi as a
proxy server when I am living abroad. Can also watch live tv remotely.
Can't begin to tell how pleased & I am with my setup & the RPi... Again,
beyond my wildest expectations. :D :D :D

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 10:49 am

Thank you.

I added an http output to mpd and verified that it is icecast which causes the high CPU load - if I turn off the icecast stream mpd uses only about 3% CPU.

So technically this is solved thanks. Unfortunately I cannot hear any http output :( so I need to troubleshoot that now! My mpd.conf for the http stream is same as macey's above. Any ideas on how to fix that one?

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 11:00 am

hooliganshark wrote:............. Any ideas on how to fix that one?
lc
Oxmplayer/vlc/mplayer http://localhost:{yourportnumber}, Either locally or remote (if you have port forwarded via ssh tunnel.

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 11:37 am

Thanks Macey :)

turns out I was simply trying to use the wrong player (deadbeef) - oops. Working with mplayer. Currently CPU use is between 15 and 20%. There are some hiccups eg when first starting to play but then it seems to settle down. Occasionally pausing still - maybe I should increase cache size? I am nervous about that though as I still have a lag problem with the client (gmpc) - there is a delay of about 10 seconds. It seems even worse than with icecast.

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 12:04 pm

hooliganshark wrote:Thanks Macey :)

turns out I was simply trying to use the wrong player (deadbeef) - oops. Working with mplayer. Currently CPU use is between 15 and 20%. There are some hiccups eg when first starting to play but then it seems to settle down. Occasionally pausing still - maybe I should increase cache size? I am nervous about that though as I still have a lag problem with the client (gmpc) - there is a delay of about 10 seconds. It seems even worse than with icecast.
After playing around with this for months, I have come to the conclusion that VLC is the best player to use (at least for me it is). Do not need a declared 'cache'. VLC seems to automatically adjust itself to the stream
after a few seconds settling down. I use :-

Code: Select all

cvlc http://localhost:660n
I have 4 streams, hence the 'n'

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 12:47 pm

hooliganshark wrote:Thanks Macey :)

turns out I was simply trying to use the wrong player (deadbeef) - oops. Working with mplayer.............................with the client (gmpc...........
I am a little confused about your setup..
Using mplayer but 'client is gmpc?
Pls explain?

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 1:57 pm

Pi+USB hard drive both powered by USB hub, connected to router by wired network connection. Flac files on USB drive, Pi running MPD now with http stream. No audio output device connected to the Pi at present

I have been controlling MPD with gmpc from my (fedora) laptop and had been using deadbeef to listen to the stream - this worked with icecast but not http for some reason. Now using vlc as suggested. Gmpc is pretty flaky for me - often crashes or loses the connection to the server, and there seems to be a 10 second lag. Previously I had thought the CPU problem was causing the lag.

The target is to be able to control the Pi and listen to music on my android phone/tablet anywhere over home network and remotely. I would then move onto the same with video.This is also a way for me to learn a bit about linux, using the command line, seeing what can be done with the Pi etc. Would welcome other ideas which might improve the result or the learning...

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 2:53 pm

hooliganshark wrote:..........................target is to be able to control the Pi and listen to music on my android phone/tablet anywhere over home network and remotely. I would then move onto the same with video..................
This is exactly what I do with my setup, stream audio, video, recorded tv, live tv all to my Linux handheld (Nokia N900). In addition to running an apache2 server.
All that was required was raspbian, mpd, mpc (and/or ncmpcpp) TVheadend
and on client vlc and mpc. Even works via 3G /2g.

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 3:16 pm

Sounds really neat. Hoping to do the same - appreciate your help. Never used TVheadend so that will be next...

Also great to know that someone else is still using the N900 :) I still use mine as my all purpose music/radio player despite android... can't bear to part with it.

macey
Posts: 58
Joined: Thu May 24, 2012 6:05 pm

Re: MPD and high CPU usage

Wed Jul 03, 2013 3:35 pm

hooliganshark wrote:...............still using the N900 :) I still use mine as my all purpose music/radio player despite android... can't bear to part with it.
.
Wouldn't be without mine either (I have two).
Interestingly(?), this topic (streaming tv from server) is how I first stumbled
upon the N900, came across a posting from someone who was streaming live cricket (UK) to his workplace desk in South Africa. I just went on learning from thereon.
Good luck & learning... :)

hooliganshark
Posts: 10
Joined: Mon Jun 17, 2013 11:18 pm

Re: MPD and high CPU usage

Mon Jul 08, 2013 9:47 pm

An update...

Thanks to the help here I switched to http streaming and that solved the CPU usage issue, since no transcoding was going on. But despite CPU usage being below 20% I still experience random dropouts or pauses which I am unable to explain. These happen both with a laptop (GMPC) and android tablet (VLC) as the playback devices.

By comparison I can stream the same files via a minidlna server without these issues - and AFAIK minidlna is not able to transcode! So perhaps there is still something in my sound setup?

The minidlna solution would be nice but it refuses to see all my files :( and anyway, I really like mpd.

Thanks for all the help so far, will continue to work on this.

PS my pi is 256mb ram

warp
Posts: 4
Joined: Wed Aug 21, 2013 10:03 pm

Re: MPD and high CPU usage

Wed Aug 21, 2013 10:10 pm

@Macey
I am a little confused about your setup..
Using mplayer but 'client is gmpc?
Pls explain?
I do exectly that when using GMPC and having output on same system. (server:6600)
GMPC has, AFAIK, no settings for http stream server:8000

Maybe you can enlighten me when there is such an option, I've been looking for ages and everywhere.
Thanks

gondman
Posts: 8
Joined: Sun Dec 30, 2012 10:05 am

Re: MPD and high CPU usage

Mon Nov 25, 2013 6:02 am

Hi,

I found this thread because i am looking for people that have some problems with pi+mpd+pulseaudio+wifi and frequnet pause of music playback. I use the following setup:

- wifi hardware: Edimax - EW-7811Un (http://www.edimax.com/en/produce_detail ... 7&pl1_id=1)
- mpd.conf

Code: Select all

audio_output {
        type            "pulse"
        name            "PulseAudio USB"
#       server          "remote_server"         # optional
        sink            "alsa_output.usb-0d8c_C-Media_USB_Headphone_Set-00-Set.analog-stereo"   # optional
}
My pi also makes frequently 5-10sec pause and sometimes mpd crashes completly. After this complete crash i startet gmpc press "stop" and "play" and everything works fine :?
Are there any ideas to solve this problems :(

warp
Posts: 4
Joined: Wed Aug 21, 2013 10:03 pm

Re: MPD and high CPU usage

Tue Nov 26, 2013 5:10 pm

warp wrote:@Macey
I am a little confused about your setup..
Using mplayer but 'client is gmpc?
Pls explain?
I do exectly that when using GMPC and having output on same system. (server:6600)
GMPC has, AFAIK, no settings for http stream server:8000

Maybe you can enlighten me when there is such an option, I've been looking for ages and everywhere.
Thanks
Ah, been looking for a solution and found that my Puppy Linux GMPC did not have the shout plugin.
So: GMPC server:6000 and Shout plugin server:8000

Return to “Media centres”