Raspberry Pi Stream Live Ham Radio/Police Scanner Audio

The Experiment: In this experiment were going to use nginx/rtmp, avconv open source free-ware to explore the possibility of streaming  live Ham Radio, Police Scanner, Microphone Audio from a Raspberry Pi Streaming Audio Server.  To listen to the Audio stream requires a RTMP compatible player.

Table of Contents

1. Required Software
2. Raspberry Pi Software Install
Raspbian Debian Wheezy
NGinx / RTMP
2. Hardware
3. Prototype
4. Notes
5. Conclusion


Raspberry Pi
1. Raspbian Debian Wheezy
2. NGinx / RTMP
3. Avconv

Windows PC
1. Putty
2. Adobe Flash-8


Raspberry Pi Software Install

Raspbian Debian Wheezy .img on SD

1. Download the Raspbian Debian Wheezy here
2. Installing Operating System Images here Linux Mac OS Windows

Install NGinx / RTMP

1. sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
2. sudo mkdir /nginx
3. sudo wget http://nginx.org/download/nginx-1.7.7.tar.gz
4. sudo wget https://github.com/arut/nginx-rtmp-module/archive/master.zip
5. sudo tar -zxvf nginx-1.7.7.tar.gz
6. sudo unzip master.zip
7. cd nginx-1.7.7
8.sudo ./configure –with-http_ssl_module –add-module=../nginx-rtmp-module-master
9. sudo make
10. sudo make install

Start nginx server
1. sudo /usr/local/nginx/sbin/nginx

Verify that NGINX server is running
1. Launch browser with nginx server IP Address

Update RTMP in nginx.conf
1. sudo nano /usr/local/nginx/conf/nginx.conf
2. Copy/Past Text below at end of the nginx.conf file

#RTMP server
rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;

3. Ctrl+x-y-<enter>

Stop NGINX server
1. sudo /usr/local/nginx/sbin/nginx -s stop

Start the NGINX server
1. sudo /usr/local/nginx/sbin/nginx

Set Default Audio Card
1. sudo nano /etc/modprobe.d/alsa-base.conf
#Keep snd-usb-audio from beeing loaded as first soundcard
Find the line below and place a # sign in front of it
options snd-usb-audio index=-2
#options snd-usb-audio index=-2
Under that past:
options snd-usb-audio index=0
options snd_bcm2835 index=1
2. Ctrl+x-y<enter>

Update rc.local
1. sudo nano /etc/rc.local
2. Copy/Past text in italic below after

# By default this script does nothing.

# Start NGINX /RTMP server
sudo /usr/local/nginx/sbin/nginx

# Start avconv audio stream

(See Notes: 1-2 & 3 comments)

3. Ctrl+x-y-<enter>

Create a Flash crossdomain.xml
1. sudo nano /usr/local/nginx/html/crossdomain.xml
2. Copy/Past text below

<?xml version="1.0"?>
<allow-access-from domain="*.host.com" />
<allow-access-from domain="*" />

3. Ctrl+x-y<enter>

Install Avconv
1. sudo apt-get install libav-tools

Verify that avconv is installed
1. sudo avconv -h

Reboot Raspberry Pi
1. sudo shutdown -r now

Uninstall Avconv
1. sudo apt-get purge libav-tools
2. sudo apt-get –purge autoremove

Install FFmpeg
1. sudo apt-get update
2. sudo apt-get install ffmpeg

Uninstall FFmpeg
1. sudo apt-get remove ffmpeg
2. sudo apt-get –purge autoremove



1. Audio Interface here
2. USB Sound Card


Custom Flash Player


1. Avconv/FFmpeg stops streaming after 31/2 – 4 hours.
2. No longer starting avconv in rc.local, now using a cron scheduled task liveStream.
3. The liveStream script runs every (Second) to keep avconv alive when it stops.

Create liveStream script
1. sudo nano /home/pi/liveStream
2. Copy/Past script below

#! /bin/sh

# Starts and Stops liveStream
# /home/pi/liveStream

# Provides: liveStream
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: liveStream Audio

#Load up liveStream when called
case "$1" in


if [ "$(pidof avconv)" ]
echo "liveStream Running"
echo "Starting liveStream.."
sudo arecord -f cd -D plughw:0,0 | avconv -i pipe:0 -f flv -preset ultrafast -tune zerolatency rtmp:// &amp;



echo "Stopping liveStream.."
sudo pkill --signal SIGINT -x avconv


echo "Usage: $0 {start|stop}"
exit 1

exit 0

3. Ctrl+x-y-<enter>

Schedule a Cron task
1. sudo crontab -e
2. Copy/Past text below

# liveStream
* * * * * /home/pi/liveStream start

3. Ctrl+x-y-<enter>

4. Audio latency about 1 second, but that’s fine for just listings to online receiver audio.



This experiment show that it is possible to stream live online audio from a Raspberry Pi.