httpd stream terminates after 25 mins

Need help with MPD?
Post Reply
robertdaly
Posts: 6
Joined: March 4th, 2020, 3:39 pm

httpd stream terminates after 25 mins

Post by robertdaly »

Hi,
I have httpd streaming enabled with the following config.
I can connect to port 8001 in a browser, or via a music player and listen to the stream. However, the stream always terminates after 25 mins. Reconnecting to the stream gives me another 25 mins and then it terminates again.

The following error message is displayed by mpv when it terminates after 25mins:

Code: Select all

[ffmpeg/audio] pcm_s16le: Multiple frames in a packet.
(Buffering) A: 00:25:21 / 00:25:21 (99%) Cache: 0.0s

Code: Select all

audio_output {
    type          "httpd"
    name          "My HTTP Stream"
    encoder       "wave"        # flac, lame, null, shine, twolame, opus, vorbis, wave
    port          "8001"
    quality "10"
    format        "44100:16:2"
    always_on     "yes"            # prevent MPD from disconnecting all listeners when playback is stopped.
    tags           "yes"           # httpd supports sending tags to listening streams.
}
Does anyone know what could be wrong in my setup, or what is causing the 25min timeouts?

max
Forum team
Posts: 1024
Joined: January 15th, 2013, 3:43 pm

Re: httpd stream terminates after 25 mins

Post by max »


robertdaly
Posts: 6
Joined: March 4th, 2020, 3:39 pm

Re: httpd stream terminates after 25 mins

Post by robertdaly »

Code: Select all

Music Player Daemon 0.20.21

Copyright (C) 2003-2007 Warren Dukes <warren.dukes@gmail.com>
Copyright 2008-2017 Max Kellermann <max.kellermann@gmail.com>
This is free software; see the source for copying conditions.  There is NO
warranty; not even MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Database plugins:
 simple proxy

Storage plugins:
 local

Decoders plugins:
 [mad] mp3 mp2
 [mpg123] mp3
 [vorbis] ogg oga
 [oggflac] ogg oga
 [flac] flac
 [opus] opus ogg oga
 [sndfile] wav aiff aif au snd paf iff svx sf voc w64 pvf xi htk caf sd2
 [audiofile] wav au aiff aif
 [dsdiff] dff
 [dsf] dsf
 [faad] aac
 [mpcdec] mpc
 [wavpack] wv
 [modplug] 669 amf ams dbm dfm dsm far it med mdl mod mtm mt2 okt s3m stm ult umx xm
 [sidplay] sid mus str prg P00
 [wildmidi] mid
 [fluidsynth] mid
 [adplug] amd d00 hsc laa rad raw sa2
 [ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 adx afc aif aifc aiff al alaw amr anim apc ape asf atrac au aud avi avm2 avs bap bfi c93 cak cin cmv cpk daud dct divx dts dv dvd dxa eac3 film flac flc fli fll flx flv g726 gsm gxf iss m1v m2v m2t m2ts m4a m4b m4v mad mj2 mjpeg mjpg mka mkv mlp mm mmf mov mp+ mp1 mp2 mp3 mp4 mpc mpeg mpg mpga mpp mpu mve mvi mxf nc nsv nut nuv oga ogm ogv ogx oma ogg omg opus psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tak tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav webm wma wmv wsaud wsvga wv wve
 [gme] ay gbs gym hes kss nsf nsfe sap spc vgm vgz
 [pcm]

Filters:
 libsamplerate

Tag plugins:
 id3tag

Output plugins:
 shout null fifo alsa roar ao oss openal pulse jack httpd recorder

Encoder plugins:
 null vorbis opus lame wave flac

Input plugins:
 file alsa curl ffmpeg

Playlist plugins:
 extm3u m3u pls soundcloud flac cue embcue

Protocols:
 file:// http:// https:// gopher:// rtp:// rtsp:// rtmp:// rtmpt:// rtmps:// alsa://

Other features:
 avahi epoll icu inotify ipv6 tcp un
This is my config file:

Code: Select all

bind_to_address "*"

db_file			"/home/mpd/database"
log_file		"/home/mpd/log"

pid_file			  "/home/mpd/pid"
state_file			"/home/mpd/state"
sticker_file	  "/home/mpd/sticker.sql"

music_directory		  "/mnt/NAS/Music"
playlist_directory	"/mnt/NAS/Music/Playlists"

port				  "6600"
auto_update   "no"

audio_output {
  type            "fifo"
  name            "my pipe"
  path            "/tmp/snapfifo"
  format          "48000:16:2"
  mixer_type      "software"
}

audio_output {
    type          "httpd"
    name          "My HTTP Stream"
    encoder       "wave"        # flac, lame, null, shine, twolame, opus, vorbis, wave
    port          "8001"
    quality "10"
    format        "44100:16:2"
    always_on     "yes"            # prevent MPD from disconnecting all listeners when playback is stopped.
    tags           "yes"           # httpd supports sending tags to listening streams.
}


user				"mpd"
group				"mpd"

I can't see any info in the log file that would indicate what is wrong

robertdaly
Posts: 6
Joined: March 4th, 2020, 3:39 pm

Re: httpd stream terminates after 25 mins

Post by robertdaly »

I have increased the log level to verbose and will see if that produces any more relevant info

max
Forum team
Posts: 1024
Joined: January 15th, 2013, 3:43 pm

Re: httpd stream terminates after 25 mins

Post by max »

The page says: "make sure you have the latest MPD version (0.21.20)"
Did you miss that?

robertdaly
Posts: 6
Joined: March 4th, 2020, 3:39 pm

Re: httpd stream terminates after 25 mins

Post by robertdaly »

Sorry, missed that. I'll try that now.

In the meantime I had increased logging to verbose and waited until I hit another timeout. There was information logged when the stream started, but not when the 25min timeout was hit:

Logs:

Code: Select all

Mar 05 07:15 : client: [0] opened from 127.0.0.1:34274
Mar 05 07:15 : client: [0] process command "play"
Mar 05 07:15 : output: opened plugin=fifo name="my pipe" audio_format=48000:16:2
Mar 05 07:15 : libsamplerate: setting samplerate conversion ratio to 1.09
Mar 05 07:15 : output: converting in=44100:24:2 -> f=44100:24:2 -> out=48000:16:2
Mar 05 07:15 : output: opened plugin=httpd name="My HTTP Stream" audio_format=44100:16:2
Mar 05 07:15 : output: converting in=44100:24:2 -> f=44100:24:2 -> out=44100:16:2
Mar 05 07:15 : client: [0] command returned 0
Mar 05 07:15 : client: [0] closed
Mar 05 07:15 : state_file: Saving state file /home/mpd/state
In mpv (the player I was using to stream), this is what it showed after 25 mins:

Code: Select all

AO: [coreaudio] 44100Hz stereo 2ch s16
A: 00:25:21 / 00:25:21 (99%) Cache: 0.1s/13KB
[ffmpeg/audio] pcm_s16le: Multiple frames in a packet.
[ffmpeg/audio] pcm_s16le: Invalid PCM packet, data has size 3 but at least a size of 4 was expected
Error decoding audio.
(Buffering) A: 00:25:21 / 00:25:21 (99%) Cache: 0.0s

robertdaly
Posts: 6
Joined: March 4th, 2020, 3:39 pm

Re: httpd stream terminates after 25 mins

Post by robertdaly »

I have upgraded mpd to version 0.21.20 and unfortunately I see the timeout - again after exactly "25:21"

Code: Select all

A: 00:25:21 / 00:25:21 (99%) Cache: 0.1s/22KB
[ffmpeg/audio] pcm_s16le: Multiple frames in a packet.
(Buffering) A: 00:25:21 / 00:25:21 (99%) Cache: 0.0s

max
Forum team
Posts: 1024
Joined: January 15th, 2013, 3:43 pm

Re: httpd stream terminates after 25 mins

Post by max »

I think after 25 minutes, the maximum size of the WAV file is hit. WAV is not suitable as a streaming format; the header needs to have a length specification, and after that, the file ends. All MPD can do is use a large value for the length (which is limited to 32 bit), and MPD will continue streaming after that, but if a client is strict, he will stop after the declared number of bytes (rightly so).
Just don't use WAV for streaming.

robertdaly
Posts: 6
Joined: March 4th, 2020, 3:39 pm

Re: httpd stream terminates after 25 mins

Post by robertdaly »

Ok, thanks for the reply. I picked wave format because when trying out the different streaming config that one seemed to produce the least load on the server and bandwidth wasn't a problem. I assumed because it didn't need to do much transcoding?

In your opinion, what would be a good choice for streaming format if i'm not constrained by bandwidth but would like to the keep resource utilisation low?

max
Forum team
Posts: 1024
Joined: January 15th, 2013, 3:43 pm

Re: httpd stream terminates after 25 mins

Post by max »

MPD can output raw PCM using the "null" encoder plugin https://www.musicpd.org/doc/html/plugins.html#null
This is without any headers, so you need a player which supports this.
I don't recommend that because it's fragile, but MPD has only those two encoder plugins for uncompressed transfer. If you know a good container format for streaming raw PCM, write a feature request on GitHub.

skidoo
Posts: 194
Joined: April 28th, 2013, 10:06 pm
Location: Western Germany

Re: httpd stream terminates after 25 mins

Post by skidoo »

robertdaly wrote:
March 5th, 2020, 3:51 pm
what would be a good choice for streaming format if i'm not constrained by bandwidth but would like to the keep resource utilisation low?
encoder "flac" wtih compresseion "0" or "1" should work well even on modest hardware.

Post Reply