PDA

View Full Version : Is streaming of raw pcm to mplayer possible?



Johan Camps
2004-03-03, 15:15
Hi!

I started my "jukebox and learing linux"-project on an old K6II-400 machine
running linux a year ago.
After ripping my entire CD collection to 320 kbit/s MP3's I discovered
SlimServer and the squeezebox.

Currently I use SlimServer to stream to mplayer which is running in a
console window on the server itself using:
# mplayer -novideo -quiet -cache 500 http://127.0.0.1:9000/stream.mp3
The output is being sent to a cmi8738-based soundcard with an optical output
connected to my home cinema receiver. A poor man's solution, but it sounds
great so far!


Since I have some multichannel .WAV files in my collection, I started to
wonder if it would be possible to stream a raw pcm stream to mplayer (making
it behave like a squeezebox ;-) )
I read the discussion archives up to three months ago, but couldn't find
someone with similar ideas.

First, I did some testing to see if mplayer would take such a stream at all:

# cat test.wav |mplayer -novideo -rawaudio on -
->Produces the correct sound for stereo .wav as well as surround .wav files.

# flac -dcs --force-raw-format --endian=little --sign=signed test.flac
|mplayer -novideo -rawaudio on -
-> Produces the correct sound for stereo .flac as well as surround .flac
files. Adds 5% processor load.

# lame --silent --decode -t test.mp3 -|mplayer -novideo -rawaudio on -
-> Produces the correct sound for stereo .mp3's. Adds 20% processor load.

So, I added the following lines at the end of convert.conf and restarted the
server

=================
# mplayer on jukebox starts here
# target is to stream raw PCM instead of MP3 info
# http because it is a non slimp device (mplayer!)
#

mp3 wav http 127.0.0.1
$lame$ --silent --decode -t $FILE$ -

aif aif http 127.0.0.1
-

wav wav http 127.0.0.1
-

flc wav http 127.0.0.1
$flac$ -dcs --force-raw-format --endian=little --sign=signed $FILE$

ogg wav http 127.0.0.1
$oggdec$ -Q -o - -R 1 $FILE$

wma wav http 127.0.0.1
$ffmpeg$ -v 0 -i $FILE$ -f wav -
=================

If I then start mplayer:
#mplayer -novideo -rawaudio on http://127.0.0.1:9000/stream.mp3

Even without any songs playing, I hear a low level bee-like buzz. (I was
expecting silence)
If I start playing a .wav/.mp3/.flac file I hear loud static. (I was
expecting music)

My guess is that slimserver is still sending out a mp3 stream.

Is it something I missed in the convert.conf file, or am I missing a point
somewhere.

Some hints would be greatly appreciated!

kdf
2004-03-03, 16:02
Quoting Johan Camps <jcamps (AT) hotmail (DOT) com>:

> Hi!
>
> I started my "jukebox and learing linux"-project on an old K6II-400 machine
> running linux a year ago.
> After ripping my entire CD collection to 320 kbit/s MP3's I discovered
> SlimServer and the squeezebox.
>
> Currently I use SlimServer to stream to mplayer which is running in a
> console window on the server itself using:
> # mplayer -novideo -quiet -cache 500 http://127.0.0.1:9000/stream.mp3
> The output is being sent to a cmi8738-based soundcard with an optical output
>
> connected to my home cinema receiver. A poor man's solution, but it sounds
> great so far!
>
>
> Since I have some multichannel .WAV files in my collection, I started to
> wonder if it would be possible to stream a raw pcm stream to mplayer (making
>
> it behave like a squeezebox ;-) )
> I read the discussion archives up to three months ago, but couldn't find
> someone with similar ideas.
>
> First, I did some testing to see if mplayer would take such a stream at all:
>
> # cat test.wav |mplayer -novideo -rawaudio on -
> ->Produces the correct sound for stereo .wav as well as surround .wav files.
>
> # flac -dcs --force-raw-format --endian=little --sign=signed test.flac
> |mplayer -novideo -rawaudio on -
> -> Produces the correct sound for stereo .flac as well as surround .flac
> files. Adds 5% processor load.
>
> # lame --silent --decode -t test.mp3 -|mplayer -novideo -rawaudio on -
> -> Produces the correct sound for stereo .mp3's. Adds 20% processor load.
>
> So, I added the following lines at the end of convert.conf and restarted the
>
> server
>
> =================
> # mplayer on jukebox starts here
> # target is to stream raw PCM instead of MP3 info
> # http because it is a non slimp device (mplayer!)
> #
>
> mp3 wav http 127.0.0.1
> $lame$ --silent --decode -t $FILE$ -
>
> aif aif http 127.0.0.1
> -
>
> wav wav http 127.0.0.1
> -
>
> flc wav http 127.0.0.1
> $flac$ -dcs --force-raw-format --endian=little --sign=signed $FILE$
>
> ogg wav http 127.0.0.1
> $oggdec$ -Q -o - -R 1 $FILE$
>
> wma wav http 127.0.0.1
> $ffmpeg$ -v 0 -i $FILE$ -f wav -
> =================
>
> If I then start mplayer:
> #mplayer -novideo -rawaudio on http://127.0.0.1:9000/stream.mp3
>
> Even without any songs playing, I hear a low level bee-like buzz. (I was
> expecting silence)
> If I start playing a .wav/.mp3/.flac file I hear loud static. (I was
> expecting music)
>
> My guess is that slimserver is still sending out a mp3 stream.
>
> Is it something I missed in the convert.conf file, or am I missing a point
> somewhere.
>
> Some hints would be greatly appreciated!

Your guess would be correct. HTTP clients only know mp3. Look for the module
Player/HTTP.pm, and then open it. Find:
sub formats { 'mp3' }
and change to:
sub formats { 'mp3','wav','aif' }
then save it.

restart the server and you should have better results.

cheers,
kdf

Richard Purdie
2004-03-03, 17:01
> Even without any songs playing, I hear a low level bee-like buzz. (I was
> expecting silence)
> If I start playing a .wav/.mp3/.flac file I hear loud static. (I was
> expecting music)
>
> My guess is that slimserver is still sending out a mp3 stream.
>
> Is it something I missed in the convert.conf file, or am I missing a point
> somewhere.
>
> Some hints would be greatly appreciated!

Simply put, the software doesn't currently do this. Only the squeezebox can
get wav/pcm streams out of the server as things stand. Work is in progress
on streaming other file formats however.

I have a patch to start the ball rolling but whilst it works, there are a
nuimber of issues to fix. It will be looked at once 5.1.1 is released.

RP

Richard Purdie
2004-03-03, 17:03
> Your guess would be correct. HTTP clients only know mp3. Look for the
module
> Player/HTTP.pm, and then open it. Find:
> sub formats { 'mp3' }
> and change to:
> sub formats { 'mp3','wav','aif' }
> then save it.
>
> restart the server and you should have better results.

I suspect this won't work as there are a lot of bits of code that do "if
squeezebox then we may be dealing with wav else deal mp3" type things. I'd
like to be proven wrong but it's not a simple problem - see my other post.
Bug 131 has a patch against it that is the start of an attempt to clean all
this up.

RP