Skip to content

Raspberry Pi USB Microphone: Stream Audio with Icecast | ShillehTek

May 10, 2024

Video Tutorial (Optional)

Watch first if you want to see the Raspberry Pi audio streaming setup in real time.

Project Overview

Raspberry Pi + USB microphone: In this project, you stream live audio from a USB microphone connected to a Raspberry Pi using Icecast and DarkIce, then listen from a local computer over the internet.

This setup is cost-effective, customizable, and works well for live discussions, podcasts, or hobby radio style streaming.

  • Time: 20 to 40 minutes
  • Skill level: Beginner
  • What you will build: A Raspberry Pi audio streaming server (Icecast) with a live audio source (DarkIce) that you can open from a computer using a stream URL

Parts List

From ShillehTek

  • No ShillehTek parts were linked in the original build.

External

  • Raspberry Pi (any model that supports Raspbian)
  • MicroSD card with Raspbian installed
  • Internet connection
  • Microphone or another audio input device (USB microphone recommended)
  • Icecast2 (software package)
  • DarkIce (software package)
  • VLC Media Player (optional, to listen to the stream) - https://www.videolan.org/

Note: This guide assumes you are installing packages on a Raspberry Pi running Raspbian (Debian-based). You will need your Icecast server IP address to tune in from another computer.

Step-by-Step Guide

Step 1 - Install Icecast on the Raspberry Pi

Goal: Install the Icecast server that will host your audio stream.

What to do: Update your package list, then install Icecast2.

Code:

sudo apt-get update; sudo apt-get install icecast2

Expected result: Icecast2 is installed, and during installation you are prompted to set basic configuration values (including passwords).

Step 2 - Install DarkIce and configure the stream

Goal: Install DarkIce so it can capture your microphone input and send it to Icecast.

What to do: Install DarkIce.

Code:

sudo apt-get install darkice

What to do: Create or edit the DarkIce configuration file at /etc/darkice.cfg and set it up like the original configuration below (adjust server, password, mount point, and metadata to match your setup).

Code:

[general]
duration = 0 # Stream indefinitely
bufferSecs = 5 # Buffer for the input, in seconds
reconnect = yes # Reconnect to the server if disconnected

[input]
device = default # Your audio capture device
sampleRate = 44100 # Sample rate in Hz
bitsPerSample = 16 # Bits per sample
channel = 2 # 2 = stereo, 1 = mono

[icecast2-0]
bitrateMode = cbr # Constant bit rate
format = mp3 # Audio format
bitrate = 128 # Bitrate in kbps
server = localhost # Server name or IP
port = 8000 # Port number
password = hackme # Your Icecast password
mountPoint = mystream # Mount point to stream to
name = My Stream # Name of the stream
description = My live stream # Description of the stream
url = http://mywebsite.com # URL related to the stream
genre = myGenre # Genre of the stream
public = no # Do not list on public lists

Expected result: DarkIce has a valid config that points to your Icecast server (often localhost on the Pi) and defines a mount point such as mystream.

Step 3 - Start streaming with DarkIce

Goal: Begin sending live microphone audio into Icecast.

What to do: Start DarkIce.

Code:

darkice

Expected result: Your stream is live and available at the Icecast URL for your mount point (for example: http://[Your_Icecast_Server_IP]:8000/mystream.mp3).

Step 4 - Tune in from your computer using VLC

Goal: Listen to the Raspberry Pi stream from a local computer.

What to do: Install VLC Media Player (if needed) from VLC's official website, then open the network stream URL.

  1. Open VLC Media Player.
  2. Go to Media -> Open Network Stream.
  3. Enter your stream URL: http://[Your_Icecast_Server_IP]:8000/mystream.mp3.

Expected result: VLC plays the live audio coming from the Raspberry Pi microphone stream.

Conclusion

You set up a Raspberry Pi audio streaming server using Icecast and DarkIce, streaming live audio from a microphone and tuning in from a computer using a standard stream URL.

Want parts for your next Raspberry Pi project? Grab what you need from ShillehTek.com. If you want help tailoring a streaming setup for your space, network, or product, check out our IoT consulting services.

Before you go, you can also support the original creator links from the post: Youtube and https://www.buymeacoffee.com/mmshilleh.