Internet Radio and Streaming Station on Brainy Pi

by aaditya04gupta in Circuits > Electronics

208 Views, 0 Favorites, 0 Comments

Internet Radio and Streaming Station on Brainy Pi

Screenshot 2023-01-28 202229.png

In this tutorial, we are going to set up a Briany Pi streaming station using DarkIce and Icecast. DarkIce and Icecast are two packages used for audio recording, encoding, and streaming.

Online radio is a digital audio service transmitted via the Internet. Broadcasting on the Internet is usually referred to as webcasting since it is not transmitted broadly through wireless means

DarkIce is a live audio streamer that records audio from an audio interface, i.e. Microphone, encodes it, and sends it to a streaming server

Icecast is an audio/video streaming media server that supports Ogg, Opus, WebM, and MP3 streams. It can be used to create everything from Internet radio stations to jukeboxes and many things in between

Supplies

Screenshot 2023-01-12 114534.png

Brainy Pi

ethernet/wifi

sd card

USB Microphone

Updating the System

Before installing any new packages we should always update the existing packages

1. To update use the command

sudo apt update

2. To upgrade use the command

sudo apt upgrade 

Installing the Req Packages

1. Before installing the DarkIce and Icecast, on the Brainy Pi we need to install the darkice deb package.

Wget https://github.com/x20mar/darkice-with-mp3-for-raspberry-pi/blob/master/darkice_1.0.1-999~mp3+1_armhf.deb?raw=true
mv darkice_1.0.1-999~mp3+1_armhf.deb?raw=true darkice_1.0.1-999~mp3+1_armhf.deb
sudo apt-get install libmp3lame0 libtwolame0
sudo dpkg -i darkice_1.0.1-999~mp3+1_armhf.deb

2. After this, we can install icecast2

sudo apt-get install icecast2

3. During the installation process, it will ask you if you want to configure Icecast2. Select Yes.

  • The next screen will ask you to specify the domain name. Select OK to use the default hostname "localhost".
  • Now, in the next steps, you will be required to add 3 passwords. The first one is to control access to media sources, the second is to use stream relays, and the third password is to grant access to the administration console. Click ‘ok’ to use the default password. The default username will be “admin”.

4. After installing Icecast2, we need to create a darkice config file to use the right sound card and talk to icecast2. Create a config file using the following command.

sudo nano darkice.cfg
  • Then copy and paste these configurations in the file:
# 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
# this section describes the audio input that will be streamed
[input]
device = plughw:0,0 # Soundcard device for the audio input
sampleRate = 22050 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16 # bits per sample. try 16
channel = 2 # 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]
[icecast2-0]
bitrateMode = abr # average bit rate
format = mp3 # format of the stream: ogg vorbis
bitrate = 320 # bitrate of the stream sent to the server
server = localhost # host name of the server
port = 8000 # port of the IceCast2 server, usually 8000
password = lolcat123 # source password to the IceCast2 server
mountPoint = Stream.mp3 # mount point of this stream on the IceCast2 server
name = Raspberry Pi Stream # name of the stream
description = Broadcast from Raspberry Pi # description of the stream
#public = yes advertise this stream?
  • Save the changes using Ctrl+X > Y > Enter.

5. Then create another file named "darkice.sh" using the below command:

sudo nano darkice.sh
  • Paste the below line in the file. This line contains the address to the configuration file.
sudo /usr/bin/darkice -c /home/pi/darkice.cfg

6. Then make the darkice.sh file executable using the below command:

sudo chmod 777 /home/pi/darkice.sh

7. Next, start the Icecast2 service using the below command:

sudo service icecast2 start

Web Interface

WhatsApp Image 2023-01-28 at 8.25.47 PM.jpeg

1. To use the web interface, you have to get the IP address of your PI

  • To get the IP address use command
hostname -I
  • There are chances that you get more than one IP address, don't worry this means you have not set the static IP address you can any IP address displayed on the terminal

2. NOW

  • With the IP in hand, you can go to the following web address in a web browser of your choice.
  • go to
 http://[PIIPADDRESS]:8000
  • Here 8000 is the port number
  • Upon going to the web address, you will be introduced to the Icecast2 web interface.

3. Click on M3U in the top right corner or enter Stream.mp3 to open the stream. If you're able to listen to the content, the stream is running properly.