Preventing MPD’s HTTP audio stream from turning silent on song change

If you stream audio in various formats from MPD to music clients, you may have run into a problem. Sometimes audio might simply go silent on a track change even though your MPD client says it’s playing the next song. This might actually have something to do with your player: some players don’t deal with audio frequency or resolution changes well. If you have audio in various resolutions and bitrates, this can trigger such a silence.

There’s one way to work around this, forcing your audio output to always have the same frequency and resolution via the format option:

audio_output {
  type        "httpd"
  name        "Whatever"
  encoder     "lame"
  port        "8001"
  bitrate     "320"     
  max_clients "8"    
  mixer_type  "software"
  format      "44100:16:2"
  always_on   "yes"
}Code language: JavaScript (javascript)

The always_on option may help as well with especially picky audio players. It produces a constant stream of silence so that there is always a bitstream for clients to receive.

A problem with this approach is of course that if you have a lot of audio in e.g. 48 KHz and 24-bit, the resulting stream will be downsampled. But you can try using e.g. 48000:24:2 in this case. I’m not sure if upsampling 44.1 KHz content to 48 KHz might introduce audible artifacting; I certainly can’t hear it.

Thanks to Neo-Desktop on GitHub for digging up my old gist about this issue and testing the workaround.

Leave a Reply

Your email address will not be published. Required fields are marked *