ralphy wrote: 
> I've not reported on my success, as I haven't been able to get the
> scripts to work consistently with my popcorn hour.  1 time in 4 play
> attempts connect and play the stream.
Thanks.  I believe the time-limiting problem was the wav file (as bpa
suggested).  I am, coincidentally, also trying flac as I write, my
script now as below.  I'm passing some environment variables so I can
ensure squeezelite and the python program do the same thing.  So far
with this version the first time I tried to connect it appeared to
succeed but didn't play, but from then on it's been  flawless.  However,
I have to wait an hour or more on my test system to know if it's going
to stop, which limits my testing opportunities.  What problems do you
get that cause it to fail?

It seems a bit silly to get my flacs converted to raw in squeezelite,
and back to flac again, but never mind. If LMS had a 'stream.flac' as
well as a 'stream.mp3' all this would be unnecessary, but I guess that's
a wish too far!

Python - playstreamMarantz (a symbolic link to the python program so I
can have multiple distinguishable copies) - a version using 'chunked'
output - change the HOST for your system:


Code:
--------------------
    
  #!/usr/bin/python
  
  import BaseHTTPServer
  import SocketServer
  import subprocess                             # For running sox
  import sys                                            # For writing to stderr
  import os                                             # For environment 
variables
  
  PORT = int(os.environ.get('VBPORT'))
  HOST = "192.168.1.10"
  BITRATE = int(os.environ.get('BITRATE'))
  DEPTH = int(os.environ.get('DEPTH'))
  
  MIMETYPE = 'audio/flac'
  BUFFER = 65536
  
  class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
  def do_HEAD(s):
  sys.stderr.write (str(s.client_address) + str(', ') + str(s.path) + str(', ') 
+ str(s.command) + '\n')
  s.send_response(200)                          # OK
  s.send_header('Content-Type', MIMETYPE)       # Wav
  s.send_header('Content-Length', '0')          # length unknown
  s.send_header('Transfer-Encoding', 'chunked') # Chunked
  s.end_headers()
  def do_GET(s):
  s.do_HEAD()                                           # Send the headers
  
  # Use flac to transform raw data to flac, using the environment variables for 
bitrate and depth (bits)
  
  pa = subprocess.Popen('flac - -c --channels 2 --bps ' +  str(DEPTH) + ' 
--sample-rate ' + str(BITRATE) + ' --endian little --sign signed --fast', shell 
= True, bufsize = BUFFER, stdout = subprocess.PIPE)    
  
  # Loop until no data, reading and writing
  
  while True:
  data = pa.stdout.read(1024)
  if len(data) == 0: break
  s.wfile.write('%X\r\n%s\r\n'%(len(data), data))
  
  # Done.  Send null chunk
  
  s.wfile.write('0\r\n\r\n')
  sys.stderr.write(str('stream closed') + '\n')
  
  # Allow the port to be re-used.  If there's a failure but the client keeps 
the port open, restarting the server can fail
  # unless this is set.
  
  SocketServer.TCPServer.allow_reuse_address = True
  httpd = SocketServer.TCPServer((HOST, PORT), Handler)
  
  sys.stderr.write(str('listening on port ') + str(PORT) + '\n')
  
  # And now do the above
  
  try:
  httpd.serve_forever()
  
  # Close if run from terminal and closed, or a sigkill/term is received.
  
  except (KeyboardInterrupt, SystemExit):
  pass                                          # Nothing
  
  httpd.server_close()
  
--------------------


Squeezelite - squeezelite-streamMarantz.sh - (using version 1.6.2 -
which works with a log file)


Code:
--------------------
    
  /home/.../Programs/squeezelite-x86-64 -o - -a $DEPTH -n Play-Stream-Marantz 
-m 00:00:00:00:00:02 -r $BITRATE -p 25 -u X -s localhost:3483 -f 
/storage/Scripts/squeezeliteMarantz.log -d output=info
  
--------------------


Main script to run the player.


Code:
--------------------
    
  pkill -SIGKILL -f playstreamMarantz
  pkill -SIGKILL -f Play-Stream-Marantz
  BITRATE=96000
  DEPTH=24
  VBPORT=8083
  export BITRATE
  export DEPTH
  export VBPORT
  /storage/Scripts/squeezelite-streamMarantz.sh 2> 
/storage/Scripts/squeezliteMarantz.err | /storage/Scripts/playstreamMarantz 2> 
/storage/Scripts/playstreamMarantz.err &
  
--------------------



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=101622

_______________________________________________
discuss mailing list
discuss@lists.slimdevices.com
http://lists.slimdevices.com/mailman/listinfo/discuss

Reply via email to