DEV Community

Cover image for Stream Audio from Raspberry Pi to Local Computer
Shilleh
Shilleh

Posted on

Stream Audio from Raspberry Pi to Local Computer

Discover the simplicity of streaming live audio directly from a USB microphone connected to your Raspberry Pi to your local computer via the internet. This step-by-step guide will walk you through the entire process, ensuring a seamless setup for real-time audio streaming.

In the digital era, streaming has become one of the most effective ways to broadcast content. Whether it's music, live discussions, or podcasts, having the capability to stream audio content live can significantly enhance your reach and engagement. Today, we’re going to guide you through setting up your own audio streaming server using a Raspberry Pi, Icecast, and DarkIce. This setup is not only cost-effective but also highly customizable and perfect for hobbyists, content creators, and small broadcasters alike.

Why Streaming Audio Is Useful

Streaming audio is increasingly popular, allowing creators and broadcasters to connect with audiences in real-time. Whether you're a musician looking to share performances live, a podcaster hosting live shows, or even a hobbyist wanting to start your own radio station, streaming is an invaluable tool. It allows instant interaction and feedback from your audience, making it a dynamic and engaging form of media.

What You’ll Need

  • Raspberry Pi (any model that supports Raspbian)
  • MicroSD card with Raspbian installed
  • Internet connection
  • Microphone or another audio input device
  • Icecast2 and DarkIce software packages
  • Before reading the remainder, be sure to subscribe and support the channel if you have not!

Subscribe:
Youtube
Support:
https://www.buymeacoffee.com/mmshilleh

Step 1: Installing Icecast on Raspberry Pi

Icecast is an open-source server designed for streaming multimedia. It acts as the backbone of your streaming operation.

Install Icecast :
sudo apt-get update; sudo apt-get install icecast2

Configure Icecast :
During the installation, you'll be prompted to configure basic settings like passwords for different types of access. Remember to secure your passwords.

Step 2: Installing Darkice

DarkIce is a live audio streamer that captures audio input and sends it to your Icecast server.

Install Darkice :
sudo apt-get install darkice

Configure Darkice :
Create or edit the DarkIce configuration file at /etc/darkice.cfg with the following settings:

[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
Enter fullscreen mode Exit fullscreen mode

Step 3: Start your Stream

Once everything is configured, start DarkIce to begin streaming:

darkice

Your stream will be live and can be accessed using the specified URL.

Tuning Into Your Stream
Once DarkIce is running, and your stream is live, you can listen to it using VLC Media Player, which can be downloaded from VLC's official website. VLC is often more efficient and offers less latency compared to browser-based streaming, providing a smoother listening experience.

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

Conclusion

Creating your own audio streaming server with a Raspberry Pi, Icecast, and DarkIce is a rewarding project that gives you full control over your digital broadcasting setup. This can be an ideal solution for anyone looking to explore the world of streaming, offering both flexibility and performance.
Don't forget to subscribe to our channel for more insightful tutorials like this, and drop us a comment if you have questions or thoughts on the setup!

Top comments (1)

Collapse
 
kitkat270 profile image
Kit

brilliant, thank you. Works well!

Not sure how to get darkice to start automatically on boot up as I'd like to run the pi headless? It needs to run as sudo on my pi3.