endru
Posts: 10
Joined: Wed Jul 19, 2017 7:34 am

MPlayer Stream Music

Thu Jul 27, 2017 4:54 pm

Hi guys,

I am trying to stream mp3's using mplayer. Doing this on different systems (Raspberry PI & Windows) I encountered some problems.

Raspberry PI (Raspbian): Installed MPlayer with mpg123 codec - Trying to start stream via URL https://example.com/api/music/stream/123 (same as windows) - following error message appears:

Playing https://example.org/api/music/stream/98. No stream found to handle url https://example.org/api/music/stream/98


Windows (10): MPlayer starting stream and gives some audio back, BUT: it starts on a randomly position, and gives following error message back: Cannot seek backward in linear streams! Also it plays only a part of a whole mp3.


Any suggestions?

User avatar
InsulationTape
Posts: 24
Joined: Sun Jul 09, 2017 1:27 pm
Location: armed with a glue gun

Re: MPlayer Stream Music

Thu Jul 27, 2017 7:03 pm

I use MPlayer pretty much all day, every day to play internet streams. Not sure exactly what the error means, but it could be that the link is actually to a playlist, rather than actually the MP3 stream.

I listen to a lot of sub.fm, and with their sources MPlayer needs the right options. Generally they have a playlist file (a plain text file) for compatibility with VLC, iTunes, Winamp etc., which details the actual audio stream. SubFM also have an embedded player on their website, these days (I think) is basically HTML5's <audio> pointed at the same stream as that in the playlist.

They make it pretty easy to tell from the URLs which is a playlist and which is the stream :)

https://www.sub.fm/listen.pls
http://stream.sub.fm:8050/SubFM

I use a wrapper on MPlayer to build a command that is reasonable for my use. Try these two, and they should work.

mplayer -cache 384 -msglevel cache=-1:identify=3:statusline=-1 -ao alsa:noblock -playlist http://www.sub.fm/listen.pls
mplayer -cache 384 -msglevel cache=-1:identify=3:statusline=-1 -ao alsa:noblock http://stream.sub.fm:8050/SubFM

If not, try outputing the audio to nowhere, just drop it with the right options, and that will say if the problem is with the audio out of MPlayer or it taking data in. If you have MPG123 installed it should work, here on my Slackware laptop that is the decoder used if I don't specify any other.

Have a look at mplayer's manpage, you can turn messages up more and more until it starts saying something that might be a bit more illuminating.

Shoutcast servers also seem to do some slight user-agent trickery. Hit a shoutcast server with a client that identifies as Mozilla* (ie normal web browsers) and the server gives an HTML status page. But hit that same server with a music player and the server gives MP3 data. This behaviour mostly means a shoutcast server can be recorded just by pointing wget at the stream.

I am a bit thrown by you saying MPlayer on Windows 10 starts at a random point. A stream off the internet is generally like an FM radio, it playing starts with whatever was going out at the exact time the radio is turned on/the software run. I hope I am not patronising you there....

A caveat though is that if you point MPlayer at an MP3 file sitting on a normal web server: what might be seen as a download can be "streamed" with the right software. For example, Sub FM have an archive of shows. You can download past shows to a file on your computer, or just give a URL to MPlayer and it will download the data, play it as audio, and throw the data away, it streams it.

"Stream" can be a synonym for broadcast, but really it is just a form of downloading. But the media industry hate the word download, so use stream to also mean other than broadcast. eg Netflix, where the user actually downloads and the (DRM'd up) software throws the data away after displaying it.

endru
Posts: 10
Joined: Wed Jul 19, 2017 7:34 am

Re: MPlayer Stream Music

Thu Jul 27, 2017 9:26 pm

First at all, thanks for your answer. Actually the stream is provided by myself (php), and its only a mp3 file which is sent as response.

Did you build the source on your own or just installed the apt-package?

Kind regards,

Andre

User avatar
InsulationTape
Posts: 24
Joined: Sun Jul 09, 2017 1:27 pm
Location: armed with a glue gun

Re: MPlayer Stream Music

Thu Jul 27, 2017 10:21 pm

I've bought a new Pi to be a media player for the lounge, but not set it up yet. But currently I mostly play music on my laptop, connected to a stereo, and that is on Slackware, using the distro's MPlayer package.

In the past I have regularly used Debian to stream music, my G4 macmini used to be a media machine in my flat. That would have been using binaries from the Deb Multimedia repository, http://www.deb-multimedia.org/ . This new Pi will get deb-multimedia as an apt source, though no doubt I will have to explore harnessing the GPU acceleration with source compiles.


You could try fiddling about with the buffer size, the -cache option, to try and get things working (there's several sub caching options documented in the man pages, too). I think MPlayer defaults to something huge like 8 meg, and if you are on a LAN then you need next to no cache - the smaller the cache the quicker playback starts.

I've seen MPlayer say "Cannot seek backward in linear streams", but can't remember when. If I try to do that by pressing left to skip back 10 seconds, it jumps back, and can only go back so far (as expected, I'm not caching much).

endru
Posts: 10
Joined: Wed Jul 19, 2017 7:34 am

Re: MPlayer Stream Music

Fri Jul 28, 2017 6:42 am

Thanks for your answer as well! Actually I would be happy if my RPI would do the same as my windows device - but it wont get there (URL not valid). It is really grinding, because It seems to be that I am the only one with such problems. Did not find anything similar ..

Kind regards,

User avatar
InsulationTape
Posts: 24
Joined: Sun Jul 09, 2017 1:27 pm
Location: armed with a glue gun

Re: MPlayer Stream Music

Sun Jul 30, 2017 1:42 pm

If you use wget on your stream's URL, does it just save a (perhaps a bit malformed, but still playable) MP3 file? It should do.

Does mplayer play an MP3 file if you just put it on your web server? Put an audio file in /var/www/htdocs (or equivalent), and then point mplayer at http://server/audio.mp3. That should play, and if not then the problem is mplayer (or at least, not your php application).

endru
Posts: 10
Joined: Wed Jul 19, 2017 7:34 am

Re: MPlayer Stream Music

Mon Jul 31, 2017 6:46 am

Thanks for your answer as well! Since I can play the stream (fragmentary) on Windows and also with the JLayer Framework on Java, I think the problem is caused by mplayer, but I have no idea why ...

endru
Posts: 10
Joined: Wed Jul 19, 2017 7:34 am

Re: MPlayer Stream Music

Thu Aug 03, 2017 10:03 am

No one else with suggestions?

Return to “Troubleshooting”