Actions

Live Audio/Ubuntu Darkice

From The RadioReference Wiki

Revision as of 13:25, 22 October 2009 by Kc2rgw (talk | contribs)

HOWTO - Ubuntu Darkice Configuration for Live Audio Feeds

Summary

This page describes the configuration for Ubuntu Linux 9.04 for darkice stream feeds for RR Live Audio feed provisioning. This should work in a generic sense for most any linux distribution using darkice, but contains some Ubuntu specific instructions for installing the packages needed to get things rolling.

Packages needed

darkice - This will take the audio feed captured, transcode it and direct the stream to the icecast/shoutcast service you are publishing to. This takes audio and converts it to mp3 stream format.

To fetch the package

Open a terminal window of your chosing.

Update your current list of packages.

sudo apt-get update

Fetch and install the software.

sudo apt-get install darkice screen

The 'screen' package will become more obvious later. It is merely an alternate way to run the darkice process in the background.

This should take care of the installation of the packages themselves and the supporting documentation. It's just that simple.

Darkice configuration

Documentation for darkice can be viewed a few ways.

man darkice 

shows the command line syntax for starting darkice

man darkice.cfg

shows details for the config file syntax

Pointing a browser at

[file:///usr/share/doc/darkice/examples/darkice.cfg local darkice example file]

The location of the sample config file in /usr/share/doc/darkice/examples/

First step is to create a configuration file or darkice won't do much of anything for you.

Here is a starter file for you. You can cut and paste this in or just copy it and create a file named darkice.cfg. The file name is not important, you can call it whatever you want.

Darkice Configuration File

# sample DarkIce configuration file, edit for your needs before using
# see the darkice.cfg man page for details

# this section describes general aspects of the live streaming session
[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

# this section describes the audio input that will be streamed
[input]
device          = /dev/dsp  # OSS DSP soundcard device for the audio input
sampleRate      = 22050     # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample   = 16        # bits per sample. try 16
channel         = 2         # channels. 1 = mono, 2 = stereo

# this section describes a streaming connection to an IceCast server
# there may be up to 8 of these sections, named [icecast-0] ... [icecast-7]
# these can be mixed with [icecast2-x] and [shoutcast-x] sections
 
# If you want to send to your own icecast server, you basically copy
# this whole section and put in the values to point the feed to your own
# server instead of the RR information below
 
# Don't forget, the name [icecast2-0] needs to change to [icecast2-1]
# and 2 and 3 as you add more feed destinations.
 
[icecast2-0]
# The audio format to encode to, we're using mp3 here
format          = mp3

# The bit rate mode to use, the commented out lines are for a fixed bit
# rate "constant bit rate" at 16 bits.  I prefer the variable bit rate
# for the sound quality it has and the throughput is very similar on avg

#bitrateMode    = cbr
#bitrate        = 16

bitrateMode     = vbr

# Quality at .1, max is 1.0, but as you increase, so does the bandwidth
# used.  For mono scanner audio .1 is totally fine.
quality         = 0.1

# Takes the input and mixes it down to a mono output for the feed.
channel         = 1

# Cuts frequency response over 5kHz.  For scanner feed this mostly
# eliminates hiss and harshness on paging tones.  Saves a bunch of
# bandwidth as well.
lowpass         = 5000

# Server shown on your RR feed owner page that hosts your feed
# You need to log in to RR, go to Account -> My Live Audio Feeds ->
# click the feed owner page icon at the far right of your feed listing.
# Then you will see all this information.

# From Feed Technical Details, the "Server"
server          = audio3.radioreference.com 

# From Feed Technical Details, the "Port"
port            = 80      # port of the IceCast server, usually 8000

# From Feed Technical Details, the Password exactly as shown
password        = PASSWD_FROM_YOUR_RR_FEED_PROVIDER_PAGE 

# From Feed Technical Details, the mount...remove the leading "/", it's
# not needed in this file.  So if it is /999999 make it just 999999
mountPoint      = MOUNT_POINT_FROM_YOUR_RR_FEED_PROVIDER_PAGE 

# name of the strea
# On My Live Audio Feeds, it's the first part ending in a colon ":"
name            = FEED NAME THAT RR GAVE YOU WHEN YOU APPLIED 

# On My Live Audio Feeds, it's the part in parentheses in the Feed name
description     = DESCRIPTION ASSIGNED FROM YOUR FEED APPLICATION 

# I don't think this is really needed because RR takes care of links
url             = http://api.radioreference.com/js/?key=XXXXXXX&feedId=XXXX
genre           = Scanner
public          = yes


Now we have a base configuration for darkice.

Starting Darkice

To start darkice, you simply have to do

darkice -c /path/to/darkice.cfg

If you don't use this computer for anything but serving this feed, you can ensure the highest quality of streaming by running darkice as root so it will get the highest time priority possible on the system. I DO NOT recommend doing this if you use the system for anything else, as it will bog it down a fair amount. If you do want to do this, change the command to.

sudo darkice -c /path/to/darkice.cfg

This should begin your stream if you have all the configuration parameters correct. Connect to your stream link and give it a bit until the latency catches up to test it. With a scanner, it may be a good idea to just open the squelch or put on NOAA so you have something with constant output to test the stream.

Now that you have it working, you need to be able to leave it running unattended if you log out of your machine.

Stopping and managing Darkice

Stop darkice by typing the following in the terminal you started it in.

ctrl-c

This literally means to hold down the ctrl key and hitting c while you hold it down. It is a 'break' sequence and stops the current running process in the terminal session.

Now start screen. This will open a 'virtual' window that will hold the running process.

screen

This will drop you to a command prompt again, so now start darkice again

darkice -c /path/to/darkice.cfg

And now it's running inside a virtual window 'screen' session. So let's get out of this and go about our business. You want to 'detach' the screen session, so type the following.

ctrl-a d

This is in literal, hitting ctrl key, pressing 'a' while doing so, then releasing and hitting 'd' to 'detach' the screen session and return to the main terminal session.

Now you are 'outside' the screen and can log out of the system and darkice will continue to run.

If you want to re-attach to the screen session, you do the following

screen -dr

This should bring you back to where you left darkice running. You'll see any error output generated if any and you can stop it if need be by typing

ctrl-c

There are a bunch of useful pages via google.com on how screen works. It's a great utility to know and understand.

You can of course make a systemwide init script so that darkice starts when the system reboots or you stop and start your system, but that's a bit beyond the scope of this article.

Closing

I hope this has been of help and please feel free to leave me a message if you used this article to get up and running with darkice. You can reach me on the forum as user KC2RGW

--Kc2rgw 13:18, 22 October 2009 (CDT)