Thanks to Graham Norbury, here is how to set up a Raspberry Pi OP25 scanner to stream audio to an icecast or other streaming server. I have updated my plug-and-play op25-rpi.img
image at http://febo.com/os_images/ to include this capability (look for the 2018-03-18_op25_rpi.zip or later-dated file).
1. Copy the following into a new file /etc/asound.conf on the Raspberry Pi (you’ll need to do this as root):
# output device
pcm.loopout {
type dmix
ipc_key 328211
slave.pcm "hw:Loopback,0,0"
}
# input device
pcm.loopin {
type dsnoop
ipc_key 686592
slave.pcm "hw:Loopback,1,0"
}
# duplex plug device
pcm.loop {
type plug
slave {
pcm {
type asym
playback.pcm "loopout"
capture.pcm "loopin"
}
}
}
pcm.mout {
type plug
slave.pcm mdev
route_policy "duplicate"
}
pcm.mdev {
type multi
slaves.a.pcm "hw:Loopback,0,0"
slaves.a.channels 2
slaves.b.pcm "hw:0,0"
slaves.b.channels 2
bindings.0.slave a
bindings.0.channel 0
bindings.1.slave a
bindings.1.channel 1
bindings.2.slave b
bindings.2.channel 0
bindings.3.slave b
bindings.3.channel 1
}
2. Copy the following into a new file /etc/modprobe.d/alsa-loop.conf on the Raspberry Pi (again, as root):
softdep snd-bcm2835 post: snd-aloop
3. Add “-O mout” to the rx.py command line.
4. Install darkice on the Raspberry Pi:
sudo apt-get install darkice
5. Copy the following into a new file /etc/darkice.cfg on the Raspberry Pi (once again, as root), and replacing the password, server name, etc. with your local info:
# 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 = 5 # size of internal slip buffer, in seconds
reconnect = yes # reconnect to the server(s) if disconnected
realtime = yes # run the encoder with POSIX realtime priority
rtprio = 3 # scheduling priority for the realtime threads
# this section describes the audio input that will be streamed
[input]
device = loop # OSS DSP soundcard device for the audio input
sampleRate = 11025 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 1 # channels. 1 = mono, 2 = stereo
# this section describes a streaming connection to an IceCast2 server
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-0]
bitrateMode = abr # average bit rate
format = vorbis # format of the stream: ogg vorbis
bitrate = 96 # bitrate of the stream sent to the server
server = MY_ICECAST_SERVER
# host name of the server
port = 8000 # port of the IceCast2 server, usually 8000
password = MY_ICECAST_PASSWORD # source password to the IceCast2 server
mountPoint = op25.ogg # mount point of this stream on the IceCast2 server
name = OP25 Scanner
# name of the stream
description = OP 25 Scanner listening to MY_SYSTEM
# description of the stream
url = http://MY_URL.com
# URL related to the stream
genre = Public Safety # genre of the stream
public = yes # advertise this stream?
localDumpFile = dump.ogg # local dump file
6. Note that this version of darkice does *not* support mp3 format; to get that you will need to compile from source, and I’m not going to go into that here.
7. Darkice can stream to an external site like Broadcastify though I am using mine to stream to a local Icecast server for consumption on my local network.
5 comments
Hi John,
I’ve found your RPI Scanner posts really useful, thank you!
I want to subscribe to your blog but your RSS feed seems to be broken – just wanted to let you know.
Hi —
Thanks for the kind words. I don’t post very often and never got around to setting up an RSS feed. I’ll look into doing that.
73,
John
Hi John,
I`m trying to use your prebuilt image to track a DMR system
155.1300
Color 12
Slot 1
Is it possible with your build?
Sorry, I can’t help you as this code is configured for a P.25 trunking system, not standalone DMR (which I’ve never actually played with).
Is there any way to make this working 2021? Following these instructions, Darkice errors out due to an issue encoding to Ogg/Vorbis. If I change up the Darkice config file to tell it to output to mp3, it KINDA works, but the audio stream is just flickers of sound instead of a full stream. We either need to know how to get Ogg/Vorbis working with Darkice, or “go into that” on how to correctly compile the mp3 version from source.