leoninuk
Posts: 12
Joined: Thu Feb 14, 2013 1:58 pm

MPD HTTP streaming reducing CPU load !

Mon May 13, 2013 8:24 pm

Hi ,

This has been probably posted before but if you have been struggling to stream music with MPD without having jittering or reaching 100% cpu load then the following might help you...

Just apply the below modification and your cpu usage will probably drop from 80%+ to around 25% on a non overclocked Pi.(stock 700mhz) with both local and HTTP playin activated.
I have tried with 2http streams+local still same CPU usage.

pre req:
1-check your sound card defaut output parameters:
sudo cat /proc/asound/card0/pcm0p/sub0/hw_params
access: RW_INTERLEAVED
format: S16_LE
subformat: STD
channels: 2
rate: 44100 (44100/1)
period_size: 5513
buffer_size: 22050


note the rate and channels above should be the same in mpd.conf


2- edit your mpd.conf
sudo nano /etc/mpd.conf

3--make the following modifications:

#
audio_output {
type "alsa"
name "My ALSA Device"
device "hw:0,0" # optional
format "44100:16:2" # CHECK rate and channels
mixer_device "default" # optional
mixer_control "PCM" # optional
mixer_index "0" # optional
}


###########################
audio_output {
type "httpd"
name "My HTTP Stream"
encoder "flac" # tjhis is the one we are using a faster encoder note that some player might not supprt Flac
port "8000"
# quality "5.0" # do not define if bitrate is defined
bitrate "96" # do not define if quality is definednote that I also changed this but thats opt leave 128 and check cpu usage...
format "44100:16:2"
}

##############################
# This setting will change all decoded audio to be converted to the specified
# format before being passed to the audio outputs. By default, this setting is
# disabled.
#
audio_output_format "44100:16:2"#uncomment
#
# If MPD has been compiled with libsamplerate support, this setting specifies
# the sample rate converter to use. Possible values can be found in the
# mpd.conf man page or the libsamplerate documentation. By default, this is
# setting is disabled.
#
samplerate_converter "Fastest Sinc Interpolator"#uncomment
#


say bye bye Jitter...

hope his will help someone,

cheers
Leo

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

Re: MPD HTTP streaming reducing CPU load !

Thu May 16, 2013 11:33 am

leoninuk wrote:Hi ,

This has been probably posted before...............................

###########################
audio_output {
type "httpd"
name "My HTTP Stream"
encoder "flac" # tjhis is the one we are using a faster encoder note that some player might not supprt Flac
port "8000"
# quality "5.0" # do not define if bitrate is defined
bitrate "96" # do not define if quality is definednote that I also changed this but thats opt leave 128 and check cpu usage...
format "44100:16:2"
}

..............................


say bye bye Jitter...

hope his will help someone,

cheers
Leo

Many thanks for this, I have been struggling for days with this, I just implemented the HTTPD plugin change & I am streaming to two destinations + local playing & seeing around 25% cpu on non-overclocked standard RasPi.

I have been searching around for ages & yours is the only post about high cpu when streaming.
If there are any others, please, can you post a link. I'd like to know if there are other fixes. I'd like to revert to vorbis if possible (I have to use mplayer on my Nokia N900 as the stock player wont play flac) .

Many thanks again :D :D

mbz
Posts: 3
Joined: Fri Sep 07, 2012 9:02 am

Re: MPD HTTP streaming reducing CPU load !

Tue Mar 04, 2014 11:39 pm

Thanx, flac encoder works so fast, I've only 12% cpu load.

But vorbis encoder works from any modern web browser ( using simple <audio> stream in html5 code ). Flac encoder works only from vlc, I have no idea how to play stream from browser.
Does anybody know how to play http flac stream from web browser? (use some kind of flash player or smth?)

Return to “Media centres”