Raspberry Pi Darkice streaming made easy

Status
Not open for further replies.

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
I have put together an SD card image for a Raspberry Pi which should work "out of the box" to set up a pi for streaming. You will need a Pi3 or earlier. It will not work on a pi4 as it is based on Raspbian Stretch Lite and the 4 requires Buster. Darkice requires pretty minimal CPU resources on the pi so any of the older pi models will work. However, the model A and PiZero do not have an ethernet jack. These could be set up wifi but I have not covered that here.
Download the .zip from the link below (be patient, it took 15 minutes to upload), unzip it to create a .img file, then image a blank SD card (min 8gb) using Etcher, win32DiskImager, or your choice. The OS is included with this image, no need to install an OS separately.



I tried to set up the image for ssh access but I am not sure this was successful. Since it is Stretch Lite there is no GUI. Plug in a usb keyboard and usb sound card and connect to an HDMI monitor. Login credentials are Username=pi and password=bcfy-pi
As long as you have a usb sound card installed, darkice will start as soon as the pi is powered up. It is streaming to an icecast server on the pi itself. With the pi connected via ethernet, go to a web browser on another computer on the same network and browse to http://piipaddress:8000 (click m3u). Determine the pi's ip address from your router setup page or using ifconfig at the command line.

Once you have successfully streamed locally, set the Pi up to stream to Broadcastify. The configuration file used is /etc/darkice1.cfg. Use the command line editor nano to edit this file. At the command line type: sudo nano /etc/darkice1.cfg There is no mouse so navigate using your arrow keys. The Section [icecast2-1] contains the broadcastify information. Enter your Server, Port, Mount (no leading slash), and Password; all from the BCFY Feed Owner Management page, Technicals Tab. Then remove the # at the start of each line in this section (uncomment). Be careful not to make any unwanted changes while editing this document. When finished it is Cntrl-x, Y, Enter to save the document.

Reboot your pi and if you got the entries correct, your BCFY stream will start.

At the command line type: sudo raspi-config to change your location and time zone as needed (image is US Eastern). Under Advanced Options, Expand the file system to the whole card.

Hide the pi away somewhere and it should stream to BCFY without any attention on your part for years. It is set to automatically reboot at 3 AM on Sundays to keep things clean.

The cheap (<$5) 3D usb sound cards on Ebay work well for this. For testing purposes, I find that streaming music from my iPhone through the audio cable into the sound card mic in jack works well. Keep the audio level low on any input to the mic jack.

Any questions, post back here.

Jim
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
If you run into difficulties, try changing device=hw:1,0 to device=2,0 in the configuration file, or vice versa.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
yup, if it is a pi4 it won't work. The OS on that image is Raspbian Stretch. The pi4 requires Buster to run. Stretch will run on all previous versions of the pi.
 

firemun

Member
Feed Provider
Joined
Dec 11, 2004
Messages
130
Location
Concord NC
yup, if it is a pi4 it won't work. The OS on that image is Raspbian Stretch. The pi4 requires Buster to run. Stretch will run on all previous versions of the pi.
The new pi is a 3B +. Bought it specifically to use for this application.
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Buster is the Operating System on the SD card. If you have the card inserted into the pi; monitor, keyboard and mouse connected; and a display showing on the screen, then you have buster running. Let us know if you have gotten this far.
 

arh2400

Member
Premium Subscriber
Joined
Feb 6, 2010
Messages
5
Location
Smith Grove, Davie County
So i have that running then.

I have attempted to follow the instructions about downloading darkice provided in the forum, moving the files per the instructions, i have edited the darkice1.cfg file with my information but i cannot get the feed to connect. if you have instructions or can guide me through the installation and what needs to be installed that would be great. Thanks in advance. if easier you can email me at smithgrove@triad.twcbc.com
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Running a darkice streamer on a raspberry pi uses very little resources of the pi. It will run perfectly well on any of the pi versions including the old original pi1. What makes the pi4 just a little bit tricky is that you need to run the Buster version or something more recent of the Raspberry Pi OS on it. The pi4 comes in versions with different amounts of RAM. If your sole interest is streaming the 1gb version is all you need. There are also three different versions of the Pi OS. I suggest that you use the the OS with desktop. There is no need for the recommended software.

Let's have a go at setting up a streamer on a pi4:

Here is a good YouTube video on obtaining the parts and setting up the pi:

Toward the end of the video he gets into setting up remote access. That is optional for this purpose.

After following his video you will be at the Pi Desktop with the operating system all updated and a connection to the internet established (either ethernet or wifi).

Plug in your usb sound card.

Open a terminal window and run these commands (the part after the $) at the command line individually:

$ sudo apt install darkice -y

$ sudo apt install icecast2 -y

$ sudo apt install screen -y

$ sudo systemctl enable icecast2.service

$ cd /etc

/etc $ sudo wget http://ttd.nfshost.com/darkice.cfg

$ sudo reboot

After the pi has rebooted, again open the terminal window and start darkice:

$ darkice

If all is working correctly, you should see an entry that ends with:


Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:2,0
Could not set POSIX real-time scheduling, this may cause recording skips.
Try to run darkice as the super-user.


This indicates that darkice is streaming properly. The note to run it as a super-user can be ignored.

At this point you are streaming to an icecast server that is running on the pi itself. From another web browser on the same network, browse to piipaddress:8000 and click on the m3u button to listen (of course, you need to use your pi's actual IP address). This arrangement works well for troubleshooting and adjusting audio levels before connecting to Broadcastify.

Once you have the audio set the way that you want it, you will need to edit the configuration file used to connect to Broadcastify. Again, at the command line:

$ sudo nano /etc/darkice.cfg

This opens the configuration file in the nano text editor. All navigation is done with the arrow keys.

The lines (red) that you want to edit are in the [icecast 2-0} section:

[icecast2-0]
bitrateMode = cbr
bitrate = 16
format = mp3
quality = .1
lowpass = 3000
server = localhost
port = 8000
password = hackme
mountPoint = 12345678


Put in the credentials that broadcastify has given you for your feed in these four lines. Be careful not to modify anything else. When complete, Control-X , Y, enter to save.

Then start your feed again using the $ darkice command. This time it should connect to broadcastify. (If you have your feed running from another source you need to shut that down before connecting here)

You will notice that whenever you close the terminal window after starting darkice, your stream will stop.

To start the stream automatically when the pi is booted up and have the stream continue without any windows open:

$ crontab -e

Scroll to the very bottom and insert this line:

@reboot screen -dmS DKICE darkice

then Cntrl-X, Y, enter to save.

Now you can shut your pi down, disconnect the keyboard, mouse and monitor, and tuck it somewhere out of the way. when you plug it in darkice will start and stream automatically and will automatically restart after a power failure.

Please post back here whether you were successful following these instructions or not. I hope that I haven't missed steps that will confuse a new user. The wiki instructions are badly outdated. If anyone wants to put these in the wiki, please do so. I have no interest in learning wiki markup just for that purpose.
 

firemun

Member
Feed Provider
Joined
Dec 11, 2004
Messages
130
Location
Concord NC
So i have that running then.

I have attempted to follow the instructions about downloading darkice provided in the forum, moving the files per the instructions, i have edited the darkice1.cfg file with my information but i cannot get the feed to connect. if you have instructions or can guide me through the installation and what needs to be installed that would be great. Thanks in advance. if easier you can email me at smithgrove@triad.twcbc.com
Dont feel like the Lone Range...Ive been trying for about 3 weeks to get a pi streaming using the info on threads in this forum...with no success. I actually took my pi and met up with a friend who has been using pis for several years for student projects etc.... After about two hours he threw in the towel and said he was out. Same as you, I have done the downloads and edit files but no luck ever connecting. I am getting close to sending mine back for a refund.
 

firemun

Member
Feed Provider
Joined
Dec 11, 2004
Messages
130
Location
Concord NC
Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:2,0
Could not set POSIX real-time scheduling, this may cause recording skips.
Try to run darkice as the super-user.
I am back working on my Pi again. I get to this point and the entry you indicate but the next line is
DarkIce: DarkIce.cpp:1273: can’t open connector [0]
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
The “can’t open connector’ may indicate that darkice can’t find the sound card. In the darkice.cfg file try using device = hw:1,0 or = hw:2,0. These can bounce around, particularly when you have an hdmi monitor connected.

if you continue to have this trouble, another option is to install pulseaudio. As long as you are only using a single usb sound card, pulse will always use that as the input (the pi has no on-board input, only an output.). To install, you can go to Add software under Raspberry Pi Configuration and search for pavucontrol. Then in the darkice.cfg file, change to device = default.
 

firemun

Member
Feed Provider
Joined
Dec 11, 2004
Messages
130
Location
Concord NC
I kept monkeying with the pi and the settings and got it connected twice and broadcastify showed it was “online”. However, I did the reboot to make sure it would restart correctly when it did reboots from the Cron tab...and then it would never reconnect. I get the message incorrect password for DarkIce. I removed and reinstalled DarkIce 2 x and could never get it to connect again. My feed site is couple hours from where I live and I am only there a 1 or 2x per month. I brought the pi back home and am going to wipe the card clean and start over...again.
 

bagman002

Newbie
Joined
Feb 7, 2012
Messages
4
Location
Sunshine Coast
Hey all. Hoping someone can shed some light on the issue that I am having.

I am running a Pi4 and I followed the above steps. I can get audio to stream to the pi itself using the local IP address. However as soon as I change the config file to include my broadcastify details I no longer get audio. Strangely enough even if I change the config file back to defaults I can no longer get audio even from local host.

Now sure what is causing it to work on first time running darkice and then not again afterwards. Flashed the OS a few times now and restarted the Pi between each config change.

Also during all my testing I have tuned into a local FM broadcast so I had something with constant audio to rule out the lack of transmissions.
 

bagman002

Newbie
Joined
Feb 7, 2012
Messages
4
Location
Sunshine Coast
Here is the contents of my darkice config file with password removed. This is a copy and paste of the details contained in this thread modified with my feed details. This file does bring my feed online just with no audio.

# sample DarkIce configuration file, edit for your needs before using
# see the darkice.cfg man page for details

# this section describes general aspects of the live streaming session
[general]
duration = 0
bufferSecs = 5
reconnect = yes

# this section describes the audio input that will be streamed
[input]
device = default # OSS DSP soundcard device for the audio input
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16
channel = 1

# this section describes a streaming connection to an IceCast2 server
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-0]
bitrateMode = cbr
bitrate = 16
format = mp3
quality = .1
lowpass = 3000
server = audio9.broadcastify.com
port = 80
password =
mountPoint =
name = FireCom North Coast
description = FireCom North Coast
genre = Public Safety
public = yes
 

DC31

Member
Feed Provider
Joined
Feb 19, 2011
Messages
1,547
Location
Massachusetts
Here is the contents of my darkice config file with password removed. This is a copy and paste of the details contained in this thread modified with my feed details. This file does bring my feed online just with no audio.

# sample DarkIce configuration file, edit for your needs before using
# see the darkice.cfg man page for details

# this section describes general aspects of the live streaming session
[general]
duration = 0
bufferSecs = 5
reconnect = yes

# this section describes the audio input that will be streamed
[input]
device = default # OSS DSP soundcard device for the audio input
sampleRate = 44100 # sample rate in Hz. try 11025, 22050 or 44100
bitsPerSample = 16
channel = 1

# this section describes a streaming connection to an IceCast2 server
# there may be up to 8 of these sections, named [icecast2-0] ... [icecast2-7]
# these can be mixed with [icecast-x] and [shoutcast-x] sections
[icecast2-0]
bitrateMode = cbr
bitrate = 16
format = mp3
quality = .1
lowpass = 3000
server = audio9.broadcastify.com
port = 80
password =
mountPoint =
name = FireCom North Coast
description = FireCom North Coast
genre = Public Safety
public = yes
it sounds like your problem may be in the device = line. “Default” likely directs it to pulseaudio which may not be installed or muted or such.

try device = hw:1,0 or device = hw:2,0
 

bagman002

Newbie
Joined
Feb 7, 2012
Messages
4
Location
Sunshine Coast
Sorry for the delay just didn't have the time to come back to this project.

This is the response I get when I change it to hw:1,0. I get a invalid value for card when I use 2,0. Although you can see from the attached image that my sound card is in fact number 1.

$ darkice
DarkIce 1.3 live audio streamer, Google Code Archive - Long-term storage for Google Code Project Hosting.
Copyright (c) 2000-2007, Tyrell Hungary, Tyrell Hungary Corporation
Copyright (c) 2008-2013, Akos Maroy and Rafael Diniz
This is free software, and you are welcome to redistribute it
under the terms of The GNU General Public License version 3 or
any later version.

Using config file: /etc/darkice.cfg
Using ALSA DSP input device: hw:1,0
Could not set POSIX real-time scheduling, this may cause recording skips.
Try to run darkice as the super-user.
DarkIce: AlsaDspSource.cpp:173: can't set channels [1]

sound card.jpg

I know it works locally but would it be best to get a different sound card? This is a 5.1 device that I had for a different project years ago.
 
Status
Not open for further replies.
Top