We look at one possible solution to stream audio applications over a network using a combination of DarkIce and IceCast 2 on Ubuntu MATE (17.10) using VLC (or any other M3U capable player).
Recently we have been experimenting with X2go for a private project. Part of that process was brushing up against audio limitations across remote desktop software. Although X2go does [supposedly] support audio we couldn't pump native Linux audio on Ubuntu MATE into a Windows' client machine.
The audio element was not part of our scope - and we wouldn't recommend it anyway - but we don't let things go easily here at GFST.com. Afterall, what is lunch break really for anyway? We simply decided to leverage the browser for an audio-only solution for a potential use case in the future.
Our test setup includes two computers that are placed 8 feet apart. One machine is used for periodic but high RAM usage but sits mostly idle throughout the day. The second machine is a workstation that includes a sound bar and small sub-woofer for multimedia. The two machines are both connected to the same internal LAN network through a simple Ethernet switch.
Our experiment utilizes the downtime of the first machine to host the audio program and streamer while our second machine simply consumes the stream and pumps it into its nice speakers without adversely effecting its own RAM resources. Nice eh?
While we were researching X2go audio options we found Zach Goldberg's Sonos instructions using IceCast 2, DarkIce and VLC circa 2012. Seemed like a perfect fit and we've worked past the configuration changes required so it works in 2018, just for you.
First, what is Icecast 2? According to the project website:
is a streaming media (audio/video) server which currently supports Ogg (Vorbis and Theora), Opus, WebM and MP3 streams. It can be used to create an Internet radio station or a privately running jukebox and many things in between.
Second, what is DarkIce? According to their website:
is a live audio streamer. It records audio from an audio interface (e.g. sound card), encodes it and sends it to a streaming server.
So the plan goes like this: audio source application > DarkIce > Icecast 2 > web > audio client (VLC) = joy.
Let's get started in the command line:
sudo apt-get install icecast2 darkice
Be sure to complete the terminal configuration when prompted. If you skip that, the rest is all worthless to you and you'll have to purge and reinstall again.
sudo nano /etc/default/icecast2
Modify the following ENABLE=false to ENABLE=true as:
# Edit /etc/icecast2/icecast.xml and change at least the passwords.
# Change this to true when done to enable the init.d script
ENABLE=true
Create a new config file in your home directory /home/YOURUSER/
and name it: .darkice.cfg
. Here's an image of ours on our streaming machine that will send the stream:
Paste the following updated configuration into your new .darkrice.cfg
file:
[general]
duration = 0 # duration of encoding, in seconds. 0 means forever
bufferSecs = 1 # size of internal slip buffer, in seconds
reconnect = yes # reconnect to the server(s) if disconnected
[input]
device = default
device = pulse
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 2 # channels. 1 = mono, 2 = stereo
[icecast2-0]
bitrateMode = vbr # variable bit rate (cbr for constant)
quality = 1.0 # 1.0 is best quality
format = mp3
bitrate = 256 # bitrate
server = localhost # or IP
port = 8000 # port for IceCast2
password = hackme
mountPoint = localhost
accesspassword = hackme # source password to the IceCast2
servermountPoint = mystream.mp3 # mount point on the IceCast2 server or any name
name = mystream
Open your browser and go to: Data Laughs for 5 Hours as your audio test source. We used Pithos but any audio application should work as long as the audio is more than a few minutes long for testing.
Start the icecast2 service:
sudo /etc/init.d/icecast2 start
Now start the DarkIce service:
sudo darkice -c ~/.darkice.cfg
You will now notice in the Sound Preferences the appearance of "ALSA plug-in [darkrice]" as shown in this image:
You will also notice in PulseAudio Volume Control the appearance of "ALSA plug-in [darkrice]: ALSA Capture" shown in this image:
Here's where things get Linux-audio-stupid. In our hosting machine, there is no active audio hardware other than the mother board as you can see in the image below, the HDMI Audio from the graphics card is disabled (no HDMI out). The profile as shown is Off. The Built-in Audio however was previously set to Analog Stereo Duplex and it had to be changed to Analog Stereo Output for IceCat 2 to "see it" and become active.
Open a browser over on your consuming device, our workstation example. The IP address will be the same IP as your audio hosting device followed by port location :8000
.
You will be greeted with the Icecast2 Status page such as:
Select the M3U link on the top right area of the page. A prompt will appear asking for you to open your default audio player that can handle the stream format. In our case this is VLC as shown below. All you have to do is press play and your stream should load. There is a slight delay. The stream is stable and can play for hours on end.
The staff at gripfastistech.com LOVES to find unique solutions to computing issues and so called "limitations" for you our future client! Please contact us with your questions or comment below to get a conversation started. As always be sure to subscribe to our RSS feed for great tips like this one; free gratis baby!
Comments powered by CComment