Streaming RTL-SDR over HTTP

Realtek makes a $20 USB software-defined radio tuner device called an RTL2832U, also known as an rtl-sdr. This chip was originally used in European TV tuners, but all kinds of demodulation are available in software. Mine has a frequency range of 48 MHz to 863 MHz but the range varies between models.

I’ve been using the amazing GQRX graphical program to browse frequencies as well as the rtl-fm command-line utilities which use way less processing power. On my low-power netbook, rtl-fm runs pretty much smoothly, and GQRX stutters some.

Screenshot of GQRX
GQRX demodulating shortwave radio. The waterfall display is shown.

The examples on the rtl-fm page show how to pipe audio data to your speakers, but what I had wanted was to stream this data over my network. This is the solution I came up with, using shell scripts.

I used LAME for mp3 encoding, and VLC for streaming. The settings used here are 320 kB/s and port 8080. I put these aliases into

alias stream8080='cvlc - --sout "#standard{access=http,mux=raw,dst=:8080}"'
alias mp3encode320='lame -r --signed -m m -s 32000 -q 9 - -'

I also put some local station shortcuts in there:

alias wort='rtl_fm -f 89.9M -M wbfm'
alias wxj87='rtl_fm -f 162.55M -N -s 32k'
alias police='rtl_fm -f 155.655M -f 857.7125 -f 158.850 -N -s 32k'

To listen to WXJ87, for example, you could run:

$ source
$ wxj87 | mp3encode320 | stream8080

Now you can use a media player to play your stream at http://localhost:8080.