How to Play LMS without SB Hardware on a Headless Linux system.  Note
that some familiarity with Linux is required.

1. Install LMS, music etc. as normal.

2. Install DLNA server of your choice, I use the excellent minimserver
from http://minimserver.com/ , autostarted at boot time (a choice when
installed in /opt/minimserver....).  Point it at your music library, or
an empty library for just this purpose if you wish.  Minimserver is very
flexible, just not as good as LMS.  If your server is headless, install
minimwatch on some other PC so you can monitor what minimserver is doing
on the server and change parameters if needs be. 

3. In the music library scanned by the DLNA server create a folder
containing http playlists of the form xyz.m3u, containing:


Code:
--------------------
    
  http:/192.168.1.10:808n/abc.flac
  
--------------------


or if you want wav format:


Code:
--------------------
    
  http:/192.168.1.10:808n/abc.wav
  
--------------------


one per network player (renderer), with an appropriate name (abc) for
each renderer, and a different port (8081, 8082 etc) for each player. 
Rescan your library so the DLNA server knows they exist.  The name (abc
in the above example) can be anything you want, but should be .flac or
.wav to tell the player what format to expect.  When, on the player, you
select the item from the playlist, you will see abc.flac (or wav), not
the xyz.m3u filename.

4. Get a copy of squeezelite somewhere it can be run easily.  Ensure
flac (for FLAC format) and/or sox (for WAV format) is installed
somewhere it can be run (check by typing 'flac' or 'sox' in a terminal).
If not natively installed there should be versions in the squeezelite
directories (/usr/share/squeezeboxserver/Bin/x86-64-linux on a 64 bit
ubuntu system). 

5. Create 2 scripts for each player/renderer.  One to run squeezelite,
one to run that script and send (pipe) the output to a python program
which puts it in a flac or wav format and sends it out via http.  Each
script should be executable.

5a) squeezelite script for version 1.6.2 or better (called
squeezelite-streamMF.sh in this case):


Code:
--------------------
    
  #!/bin/bash
  # Run squeezelite.  If version below 1.6.2, remove the -d and -f options.
  /home/crusty/Programs/squeezelite-x86-64 -o - -a $DEPTH -n Play-Stream-MF -m 
00:00:00:00:00:01 -r $BITRATE -p 25 -u VLX -s localhost:3483 -f 
/storage/Scripts/squeezeliteMF.log -d output=info
  
--------------------


Note the rate (-r)  and depth (-a) must match that in the python
program, so is set by the caller, and the (-m) MAC and (-n) Name must be
different for each player.  Set the path for your squeezelite program to
wherever it is on your system.  If you don't have it, get it from
https://code.google.com/p/squeezelite/.  The squeezelite debug log will
be in squeezeliteMF.log.  Errors will be in  squeezeliteMF.err (see
later).

5b) Script to join and execute the above, in my case called streamMF.sh
(note that all my scripts are in /storage/Scripts – put them where you
like). 


Code:
--------------------
    
  #!/bin/bash
  
  # Kill off squeezelite, then python program
  pkill -SIGKILL -f Play-Stream-MF
  pkill -SIGKILL -f playstreamMF
  
  # Note all of the following must be specified even if you don't intend to use 
one of the options
  
  export BITRATE=192000       # Set the bitrate to a valid rate (44100, 48000, 
96000, 192000)
  export DEPTH=24             # Depth to 16,24 or 32
  export VBPORT=8082          # The http port to be used
  export COMPRESSION=4        # Flac compression 0 to 8
  export HOST="192.168.1.10"  # Host IP address
  export FORMAT="WAV"        # "FLAC" or "WAV" (the default)
  
  # Executable program for flacs - can be flac or sox.  If using WAVs, set this 
to sox. 
  # If flac (or sox) is not in your normal path, specify the location fully, eg:
  #     /usr/share/squeezeboxserver/Bin/x86_64-linux/flac
  # If it is in your normal path, just enter flac or sox
  export FLACPROG="flac"      
  
  # Executable sox program for WAVs
  export WAVPROG="sox"        
  
  # Now run squeezelite, piping the stdout into the python program (using the | 
symbol)
  # The 1st 2> provides an error log for squeezelite, which should be empty
  # The 2nd 2>> provides a cumulative error and information log for the python 
program
  
  /storage/Scripts/squeezelite-streamMF.sh 2> 
/storage/Scripts/squeezeliteMF.err | /storage/Scripts/playstreamMF 2>> 
/storage/Scripts/playstreamMF.err &
  
  
--------------------


This script kills any existing squeezelite for this player, and the
associated python program, then restarts them, piping the output from
squeezelite to python, and hence flac or sox.

Hopefully the use of BITRATE, DEPTH and VBPORT is obvious.  The
COMPRESSION is the flac parameter 0 to 8 (with no preceding hypen).  The
HOST is your server (not 'localhost').  FORMAT must be FLAC or WAV.  WAV
seems more stable, but limits the length of playing time (see 12 below).
Set the name (or full path) of your flac and wav conversion programs in
WAVPROG and WAVPROG (if using WAV just set both to sox).

SqueezeliteMF.err will contain squeezelite errors.  PlaystreamMF.err
will contain any output (to stderr) from the python program (I couldn't
get it to write the start-up and closedown messages to a stdout file).

5c) python program (called playstreamMF in this case)

This is a bit too long to include in this post so it's in the following
post (I didn't use a zip file since some may not wish to download from a
thread). It is only as long as it is because I had to override some
standard functions to get rid of unnecessary traces on the error log.

Note that the flac/sox parameters in 5b above must match the output from
squeezelite so flac/sox know what they are being given.  They should
both match the capability of your player.  In my case I have one that
will play 24/96, and one will play 24/192 (as shown).  I'm showing the
24/192 example for my proof of concept to show that very high quality
can be achieved should it be wanted.

I am intentionally getting squeezelite to do all the scaling work, and
then flac or sox creates the flac or wav as appropriate.  For flac the
compression must be specified (for my Musical Fidelity, MF,  it must be
4 to 8 at 192,000khz, for my Marantz it can be 0).  The PORT must be
different for each player.  

The way I set it up, the program is actually called playstream.py, with
a symbolic link called playstreamMF pointing to it.  This means the
python process for that player has the latter name and can be killed
leaving any other(s) running.

6. To run the script, I use the very handy LMS Server Power Control
plugin. Add a repository to your LMS plugins page as follows:

http://srvrpowerctrl.googlecode.com/svn/beta.xml

And then add the plugin, restart LMS and configure the plugin as you
wish.  To start the player(s) Add a custom command:


Code:
--------------------
    
  .autoexec   /storage/Scripts/streamMF.sh
  
--------------------


This starts the player for your device some tens of seconds after LMS
starts.

I also added a command called 'Restart streaming MF' to run the same
script from the Server Power Control user menu (in Extras) if anything
goes wrong.

7. To support multiple players, create new scripts as in 5.  In 6, use a
new script which runs all your player scripts, 'streamAll.sh', as the
autoexec file in 6.


Code:
--------------------
    
  /storage/Scripts/streamMF.sh &
  /storage/Scripts/streamMarantz.sh &
  
--------------------


8. You can now use each player separately using the standard LMS web
interface.

9.  If you have a firewall in place on your server, you will need to
open the ports for the streaming above, and for the DLNA server, from
the players.

10. Minimserver shows playlists as a separate menu item on the network
music players when you view the Music Server menu.  Hopefully the same
is true of other DLNA/UPnP servers.  So on the player, select the
appropriate playlist and play it.  For ease of use, you could add it to
your player's favourite list.

11. On the LMS web page each player shows up with the name you supplied
to squeezelite (Play-Stream-MF in my example in 5a).  You can control it
just like a hardware player.

12. Why use FLAC?  With WAV files my MF stop after ~30-31 minutes.  The
Marantz after 61-62 minutes.  The rate is double to the MF.  This turns
out to be data size related.

2GB = 2^31 = 2,147,483,648
A stream of 24 * 192,000 * 2 / 8 = 1,152,000 bytes/sec.
So 2GB will be sent in 1864 seconds = 31 minutes, as observed at
24/192.

The problem is the wav file size.  I tried patching it, or the data
chunk, size to 0, but neither renderer liked it. 

So I tend to use flac, which seems crazy since the file was in flac in
the first place and has been converted to raw output by squeezelite, but
it works providing I'm playing a long series of tracks (but see 13a). 
Alternatively use wav if you like.  At CD quality (16/44100) it should
last over 3 hours.



LMS 7.9 on VortexBox Midi running Xubuntu 14.04, FLACs 16->24 bit,
44.1->192kbps. Wired Touch + EDO, coax to Musical Fidelity M1 CLiC.
Wireless Xubuntu 14.04 laptop controls LMS via Chromium.   Meridian
Explorer USB DAC to listen via Squeezelite on Vortexbox & other PCs as
required.  Spare Touch in loft.
------------------------------------------------------------------------
PasTim's Profile: http://forums.slimdevices.com/member.php?userid=41642
View this thread: http://forums.slimdevices.com/showthread.php?t=101721

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to