LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Linux Audio Streaming (server) (https://www.linuxquestions.org/questions/linux-software-2/linux-audio-streaming-server-4175441805/)

BlackRabbit 12-17-2012 02:21 PM

Linux Audio Streaming (server)
 
Situation:
- 1 linux machine (Debian Squeeze) with a collection of MP3/FLAC
- 1 Onkyo TX-NR509 A/V receiver which supports 'streaming internet radio'
- 1 set of parents with minimal computer knowledge

Idea:
- start an 'internet radio' on the linux machine
- allow 'users' to select music (make the radio act as a jukebox)
- to allow easy album/song selection, I'd like to use a web-interface

Up until now:
- I found & installed icecast, mpd, ampache (, subsonic (which is not able to fulfill my needs, it seems))
- got nothing to work

The issue:
- I know little about streaming (never used it, never set it up) & get lost in the howto's that seem to skip many a step:
* What piece of software is doing what job?
* Who should listen on/send to what port?

Requirements:
- Have 1 or more 'radio stations' (each with their own, fixed address, possibly 1 stream for each person in the house).
- Allow each user to select music for his own stream.
- If possible: have all songs normalized (to avoid silent/loud music disrupting the listening process).



My questions:
- Could someone explain how I can get this to work?
- Icecast & mpd are talking about ports, how to interpret this?
- What are the 'localplay instance' thingies in ampache? Is this 'a radio station instance'? How to access them?

Notes:
- the A/V receiver can handle MP3/OGG/FLAC/[..], so the incoming stream can be one of these.
- surfing to 'http://192.168.0.2:8000/' shows the icecast2 status page, so I guess it is working correctly?

Current configs:
Code:

# MPD.conf


# Files and directories #######################################################
#
# This setting controls the top directory which MPD will search to discover the
# available audio files and add them to the daemon's online database. This
# setting defaults to the XDG directory, otherwise the music directory will be
# be disabled and audio files will only be accepted over ipc socket (using
# file:// protocol) or streaming files over an accepted protocol.
#
music_directory                "/var/music"
#
# This setting sets the MPD internal playlist directory. The purpose of this
# directory is storage for playlists created by MPD. The server will use
# playlist files not created by the server but only if they are in the MPD
# format. This setting defaults to playlist saving being disabled.
#
playlist_directory                "/var/lib/mpd/playlists"
#
# This setting sets the location of the MPD database. This file is used to
# load the database at server start up and store the database while the
# server is not up. This setting defaults to disabled which will allow
# MPD to accept files over ipc socket (using file:// protocol) or streaming
# files over an accepted protocol.
#
db_file                        "/var/lib/mpd/tag_cache"
#
# These settings are the locations for the daemon log files for the daemon.
# These logs are great for troubleshooting, depending on your log_level
# settings.
#
# The special value "syslog" makes MPD use the local syslog daemon. This
# setting defaults to logging to syslog, otherwise logging is disabled.
#
log_file                        "/var/log/mpd/mpd.log"
#
# This setting sets the location of the file which stores the process ID
# for use of mpd --kill and some init scripts. This setting is disabled by
# default and the pid file will not be stored.
#
pid_file                        "/var/run/mpd/pid"
#
# This setting sets the location of the file which contains information about
# most variables to get MPD back into the same general shape it was in before
# it was brought down. This setting is disabled by default and the server
# state will be reset on server start up.
#
state_file                        "/var/lib/mpd/state"
#
###############################################################################


# General music daemon options ################################################
#
# This setting specifies the user that MPD will run as. MPD should never run as
# root and you may use this setting to make MPD change its user ID after
# initialization. This setting is disabled by default and MPD is run as the
# current user.
#
user                                "mpd"
#
# This setting sets the address for the daemon to listen on. Careful attention
# should be paid if this is assigned to anything other then the default, any.
# This setting can deny access to control of the daemon.
#
# For network
bind_to_address                "any"
#
# And for Unix Socket
#bind_to_address                "/var/run/mpd/socket"
#
# This setting is the TCP port that is desired for the daemon to get assigned
# to.
#
#port                                "6600"


# Input #######################################################################
#

input {
        plugin "curl"
#      proxy "proxy.isp.com:8080"
#      proxy_user "user"
#      proxy_password "password"
}

#
###############################################################################

# Audio Output ################################################################
#
# MPD supports various audio output types, as well as playing through multiple
# audio outputs at the same time, through multiple audio_output settings
# blocks. Setting this block is optional, though the server will only attempt
# autodetection for one sound card.

audio_output {
        type                "shout"
        encoding        "vorbis"                        # optional
        name                "My Shout Stream"
        host                "localhost"
        port                "9000"
        mount                "/mpd"
        password        "hackme"
        quality                "10.0"
#        bitrate                "384"
        format                "44100:16:2"
        protocol        "icecast2"                # optional
        user                "source"                # optional
        description        "My Stream Description"        # optional
        genre                "jazz"                        # optional
        public                "no"                        # optional
        timeout                "2"                        # optional
}


###############################################################################



# Normalization automatic volume adjustments ##################################
#
# This setting specifies the type of ReplayGain to use. This setting can have
# the argument "album" or "track". See <http://www.replaygain.org> for more
# details. This setting is disabled by default.
#
#replaygain                        "album"
#
# This setting sets the pre-amp used for files that have ReplayGain tags. By
# default this setting is disabled.
#
#replaygain_preamp                "0"
#
# This setting enables on-the-fly normalization volume adjustment. This will
# result in the volume of all playing audio to be adjusted so the output has
# equal "loudness". This setting is disabled by default.
#
volume_normalization                "yes"
#
###############################################################################


Code:

icecast.xml

<icecast>
    <limits>
        <clients>100</clients>
        <sources>2</sources>
        <threadpool>5</threadpool>
        <queue-size>524288</queue-size>
        <client-timeout>30</client-timeout>
        <header-timeout>15</header-timeout>
        <source-timeout>10</source-timeout>
        <burst-on-connect>1</burst-on-connect>
        <burst-size>65535</burst-size>
    </limits>

    <authentication>
        <source-password>hackme</source-password>
        <relay-password>hackme</relay-password>
        <admin-user>admin</admin-user>
        <admin-password>hackme</admin-password>
    </authentication>


    <hostname>192.168.0.2</hostname>
 <listen-socket>
        <port>8000</port>
    </listen-socket>



    <fileserve>1</fileserve>

    <paths>
        <basedir>/usr/share/icecast2</basedir>
        <logdir>/var/log/icecast2</logdir>
        <webroot>/usr/share/icecast2/web</webroot>
        <adminroot>/usr/share/icecast2/admin</adminroot>

    <alias source="/" dest="/status.xsl"/>
    </paths>

    <logging>
        <accesslog>access.log</accesslog>
        <errorlog>error.log</errorlog>

              <loglevel>3</loglevel>
              <logsize>10000</logsize>
    </logging>

    <security>
        <chroot>0</chroot>
    </security>
</icecast>


Code:

root@server:~# mpd --version
mpd (MPD: Music Player Daemon) 0.15.12

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

Supported decoders:

[mad] mp3 mp2
[vorbis] ogg oga
[oggflac] ogg oga
[flac] flac
[audiofile] wav au aiff aif
[faad] aac
[mpcdec] mpc
[wavpack] wv
[sidplay] sid
[ffmpeg] 16sv 3g2 3gp 4xm 8svx aa3 aac ac3 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 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 psp pva qcp qt r3d ra ram rl2 rm rmvb roq rpl rvc shn smk snd sol son spx str swf tgi tgq tgv thp ts tsp tta xa xvid uv uv2 vb vid vob voc vp6 vmd wav wma wmv wsaud wsvga wv wve

Supported outputs:

shout null fifo alsa ao oss pulse jack httpd

Supported protocols:

file:// http:// lastfm:// mms:// mmsh:// mmst:// mmsu://

Should 'supported outputs' mention ogg/vorbis/mp3/flac??

BlackRabbit 12-17-2012 02:51 PM

The icecast2 administration status webpage shows this:
Code:

admin        icemaster@localhost
client_connections        76
clients        1
connections        77
file_connections        12
host        192.168.0.2
listener_connections        0
listeners        0
location        Earth
server_id        Icecast 2.3.2
server_start        Mon, 17 Dec 2012 16:23:57 +0100
source_client_connections        0
source_relay_connections        0
source_total_connections        0
sources        0
stats        0
stats_connections        0



mpd.log
Code:

Dec 17 13:29 : state_file: failed to open /var/lib/mpd/state: No such file or directory
Dec 17 20:41 : client: failed to write to 2: Broken pipe
Dec 17 20:57 : client: failed to write to 0: Broken pipe
Dec 17 20:57 : client: failed to write to 2: Connection reset by peer


BlackRabbit 12-19-2012 04:47 PM

No one?

I'm guessing it has something to do with either:
- port configuration
- problems with (trans-) coding

frieza 12-19-2012 04:53 PM

the question is how far physically is the reciever from the computer, perhaps a simpler solution would be just a direct audio cable connection between the two units would be easier?

otherwise i would try using shoutcast (or icecast) and IDJC

BlackRabbit 12-19-2012 04:57 PM

Quote:

Originally Posted by frieza (Post 4853185)
the question is how far physically is the reciever from the computer, perhaps a simpler solution would be just a direct audio cable connection between the two units would be easier?

otherwise i would try using shoutcast (or icecast) and IDJC

If that would have been possible, this thread would be none-existent ;-)
Receiver is downstairs in living room, server upstairs (2 levels up).



IDJC is an actual (linux?) client. That is out of the question. I need to be able to do this from any device in the house, without installing extra software (on the clients). But thanks for the input.



Do you have experience with setting up icecast? How can I check if it is working properly?

frieza 12-19-2012 05:01 PM

perhaps i should be more clear, IDJC stands for internet DJ console, it is the 'play audio/encode stream/pass stream to shoutcast/icecast' part of the mix

schneidz 12-19-2012 05:05 PM

Code:

[schneidz@hyper ~]$ cat stuff/netcat.ksh
#!/bin/bash
PL=$(find /root/user/music -name "*.mp3")
NUM=$(echo $PL |wc -w)
{
while true; do
r=$(($RANDOM%$NUM))
s=$(echo $PL |cut -d ' ' -f$r)
echo "HTTP/1.0 200 OK\nContent-Type: audio/x-mp3stream\n\n"
dd if=$s bs=1024
done
} | nc -l -s address -p 8020


BlackRabbit 12-19-2012 05:10 PM

Quote:

Originally Posted by frieza (Post 4853196)
perhaps i should be more clear, IDJC stands for internet DJ console, it is the 'play audio/encode stream/pass stream to shoutcast/icecast' part of the mix

This, right?

It is software that runs *somewhere* (on the music-server-machine itself?), right? Point is, that machine has no monitor/videocard. VNC-access is not an option, as this requires VNC-client software and more effort of my parents.

However, I guess I can use it to test if icecast is working properly. Thanks!



Quote:

Originally Posted by schneidz (Post 4853199)
Code:

[schneidz@hyper ~]$ cat stuff/netcat.ksh
#!/bin/bash
PL=$(find /root/user/music -name "*.mp3")
NUM=$(echo $PL |wc -w)
{
while true; do
r=$(($RANDOM%$NUM))
s=$(echo $PL |cut -d ' ' -f$r)
echo "HTTP/1.0 200 OK\nContent-Type: audio/x-mp3stream\n\n"
dd if=$s bs=1024
done
} | nc -l -s address -p 8020


If I read this correctly, it plays random songs from the /root/user/music folder, putting them on a http stream on port 8020?
It's a nice & easy script, but barely what I'm asking for, I'm affraid.

BlackRabbit 12-25-2012 06:27 AM

Could someone tell me one what address I should set my media player to listen?

Tried several things, none work:
Code:

http://192.168.0.2:8000/
http://192.168.0.2:8000/mpd /* /mpd is mountpoint of MPD */
http://192.168.0.2:8000/mpd/bart /* bart is an ampache instance */
http://192.168.0.2:8000/bart /* idem */


(I'm trying both VLC & Windows Media Player on a laptop to test playback)



Summary:
Icecast is listening on port :8000
MPD is listening on port :6600
MPD is sending to port :8000

Code:

audio_output {
        type            "shout"
        encoding        "vorbis"                        # optional
        name            "My Shout Stream"
        host            "localhost"
        port            "8000"
        mount          "/mpd"
        password        "maes"
        quality        "10.0"
#      bitrate        "384"
        format          "44100:16:2"
        protocol        "icecast2"              # optional
        user            "source"                # optional
        description    "My Stream Description" # optional
        genre          "jazz"                  # optional
        public          "no"                    # optional
        timeout        "2"                    # optional
}


frieza 12-25-2012 02:06 PM

if icecast is anything like shout cast, than try pointing at port 8001, you stream TO icecast on port 8001 and stream FROM it on 8000
at least that's how shoutcast works


All times are GMT -5. The time now is 06:04 PM.